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

🔨 Fix script watching #233

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ async function main({ node, bundle } = argv) {
// handle errors
function handleError(err) {
if (!err.exitCode) console.error(err);
process.exit(err.exitCode || 1);
if (!argv.watch) process.exit(err.exitCode || 1);
}

// run everything and maybe watch for changes
main().then(() => argv.watch && (
main().catch(handleError).then(() => argv.watch && (
require('./watch')(() => main().catch(handleError))
)).catch(handleError);
));
23 changes: 13 additions & 10 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ async function main({
await new Promise(r => rimraf(path.join(cwd, '{.nyc_output,coverage}'), r));
await child('spawn', nycbin, ['--silent', '--no-clean', 'node', __filename, ...flags]);
await child('spawn', nycbin, ['report', '--check-coverage', ...flagify({ reporter })]);
} else if (testNode && testBrowsers) {
// test runners assume they have control over the entire process, so give them each their own
// forked process when both are requested to avoid processes clashing
} else if (!process.send) {
// test runners assume they have control over the entire process, so give them each forks
let flags = flagify({ coverage });

await child('fork', __filename, ['--node', ...flags]);
process.stdout.write('\n');
if (testNode) {
await child('fork', __filename, ['--node', ...flags]);
process.stdout.write('\n');
}

await child('fork', __filename, ['--browsers', ...flags]);
process.stdout.write('\n');
if (testBrowsers) {
await child('fork', __filename, ['--browsers', ...flags]);
process.stdout.write('\n');
}
} else if (testNode) {
// $ jasmine <cwd>/test/**/*.test.js --config <config>
let Jasmine = require('jasmine');
Expand Down Expand Up @@ -111,10 +114,10 @@ async function main({
// handle errors
function handleError(err) {
if (!err.exitCode) console.error(err);
process.exit(err.exitCode || 1);
if (!argv.watch) process.exit(err.exitCode || 1);
}

// run everything and maybe watch for changes
main().then(() => argv.watch && (
main().catch(handleError).then(() => argv.watch && (
require('./watch')(() => main().catch(handleError))
)).catch(handleError);
));