Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: transform support treesharking #115

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -12,6 +12,17 @@
"sourceType": "module",
"impliedStrict": true
},
"env": {
"node":true
},
"overrides": [
{
"files": ["test/**/*"],
"env": {
"jest": true
}
}
],
"rules": {
"no-sparse-arrays": 0,
"no-inner-declarations": 0,
@@ -27,6 +38,11 @@
"@typescript-eslint/ban-ts-ignore": 0,
"@typescript-eslint/no-empty-interface": 1,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-explicit-any": 0
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unsafe-declaration-merging":"off",
"@typescript-eslint/prefer-ts-expect-error":"off",
"@typescript-eslint/ban-ts-comment":"off",
"@typescript-eslint/ban-types":"off",
"@typescript-eslint/no-var-requires":"off"
}
}
17 changes: 9 additions & 8 deletions bin/screenshot.js
Original file line number Diff line number Diff line change
@@ -35,43 +35,44 @@ app.use('/', serveStatic(process.cwd()));

const DELAY = 10000;

getPort().then(port => {
getPort().then((port) => {
http.createServer(app).listen(port);
const url = 'http://127.0.0.1:' + port;
debug('server is ready on port ' + port + '! url: ' + url);

const q = queue(MAX_POOL_SIZE > 2 ? MAX_POOL_SIZE - 1 : MAX_POOL_SIZE);
const files = ls(src).filter(filename => (extname(filename) === '.html'));
files.forEach(filename => {
const files = ls(src).filter((filename) => extname(filename) === '.html');
files.forEach((filename) => {
const name = basename(filename, '.html');
if (_.isString(commander.name) && filename.indexOf(commander.name) === -1) {
debug(`>>>>>>>>> skipping because filename not matched: ${name}`);
return;
}
q.defer(callback => {
q.defer((callback) => {
const t0 = Date.now();
const nightmare = Nightmare({
gotoTimeout: 600000,
show: false
show: false,
});
const url = `http://127.0.0.1:${port}/demos/${name}.html`;
const target = join(dest, `./${name}.png`);
nightmare.viewport(800, 450) // 16 x 9
nightmare
.viewport(800, 450) // 16 x 9
.goto(url)
.wait(DELAY)
.screenshot(target, () => {
debug(name + ' took ' + (Date.now() - t0) + ' to take a screenshot.');
callback(null);
})
.end()
.catch(e => {
.catch((e) => {
debug(url);
debug(target);
debug(name + ' failed to take a screenshot: ' + e);
});
});
});
q.awaitAll(error => {
q.awaitAll((error) => {
if (error) {
debug(error);
process.exit(1);
Loading