From e3fcb580d9f893ccae318a2821256768aaa4c689 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Wed, 15 May 2019 14:25:36 -0400 Subject: [PATCH 1/4] Declare processConfigsErr before use --- bin/src/run/watch.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/src/run/watch.ts b/bin/src/run/watch.ts index d09ab82bff2..eec4d29f078 100644 --- a/bin/src/run/watch.ts +++ b/bin/src/run/watch.ts @@ -42,6 +42,7 @@ export default function watch( const warnings = batchWarnings(); + let processConfigsErr: any; const initialConfigs = processConfigs(configs); const clearScreen = initialConfigs.every(config => config.watch.clearScreen !== false); @@ -52,8 +53,6 @@ export default function watch( let watcher: Watcher; let configWatcher: Watcher; - let processConfigsErr: any; - function processConfigs(configs: RollupWatchOptions[]): RollupWatchOptions[] { return configs.map(options => { const merged = mergeOptions({ From b9d83c64a3e7f7d34febe41e86f271b3fac4dc4f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 17 May 2019 11:13:23 +0200 Subject: [PATCH 2/4] Add test to check watch.clearScreen:false no longer causes an error --- test/cli/index.js | 10 ++++++++-- test/cli/samples/watch/_config.js | 9 +++++++++ test/cli/samples/watch/_expected.js | 0 test/cli/samples/watch/foo.js | 1 + test/cli/samples/watch/main.js | 3 +++ test/cli/samples/watch/rollup.config.js | 10 ++++++++++ 6 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/cli/samples/watch/_config.js create mode 100644 test/cli/samples/watch/_expected.js create mode 100644 test/cli/samples/watch/foo.js create mode 100644 test/cli/samples/watch/main.js create mode 100644 test/cli/samples/watch/rollup.config.js diff --git a/test/cli/index.js b/test/cli/index.js index 325f488b5c5..a94152a4c6a 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -25,8 +25,8 @@ runTestSuiteWithSamples( const command = 'node ' + path.resolve(__dirname, '../../bin') + path.sep + config.command; - exec(command, {}, (err, code, stderr) => { - if (err) { + const childProcess = exec(command, {}, (err, code, stderr) => { + if (err && !err.killed) { if (config.error) { const shouldContinue = config.error(err); if (!shouldContinue) return done(); @@ -111,6 +111,12 @@ runTestSuiteWithSamples( } } }); + + childProcess.stderr.on('data', data => { + if (config.abortOnStderr && config.abortOnStderr(data)) { + childProcess.kill('SIGINT'); + } + }); } ); }, diff --git a/test/cli/samples/watch/_config.js b/test/cli/samples/watch/_config.js new file mode 100644 index 00000000000..85833195535 --- /dev/null +++ b/test/cli/samples/watch/_config.js @@ -0,0 +1,9 @@ +module.exports = { + description: 'does not fail in watch-mode with clearScreen: false', + command: 'rollup -cw', + abortOnStderr(data) { + if (data.includes('created')) { + return true; + } + } +}; diff --git a/test/cli/samples/watch/_expected.js b/test/cli/samples/watch/_expected.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/cli/samples/watch/foo.js b/test/cli/samples/watch/foo.js new file mode 100644 index 00000000000..3b8dc9fedfc --- /dev/null +++ b/test/cli/samples/watch/foo.js @@ -0,0 +1 @@ +export var foo = 42; diff --git a/test/cli/samples/watch/main.js b/test/cli/samples/watch/main.js new file mode 100644 index 00000000000..8ab8dbd37ef --- /dev/null +++ b/test/cli/samples/watch/main.js @@ -0,0 +1,3 @@ +import { foo } from './foo.js'; + +assert.equal( foo, 42 ); diff --git a/test/cli/samples/watch/rollup.config.js b/test/cli/samples/watch/rollup.config.js new file mode 100644 index 00000000000..1b6e0556847 --- /dev/null +++ b/test/cli/samples/watch/rollup.config.js @@ -0,0 +1,10 @@ +export default { + input: 'main.js', + output: { + file: '_actual.js', + format: 'esm' + }, + watch: { + clearScreen: false + } +}; From 4ef6336425a76fdc903df10cbf5781c52d84869f Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 17 May 2019 12:05:55 +0200 Subject: [PATCH 3/4] Use a more powerful killing mechanism --- test/chunking-form/samples/manual-chunks-function/_config.js | 1 - test/cli/index.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/chunking-form/samples/manual-chunks-function/_config.js b/test/chunking-form/samples/manual-chunks-function/_config.js index 0ea976037f8..7dce4fbb810 100644 --- a/test/chunking-form/samples/manual-chunks-function/_config.js +++ b/test/chunking-form/samples/manual-chunks-function/_config.js @@ -4,7 +4,6 @@ module.exports = { input: ['main-a'], manualChunks(id) { if (id[id.length - 5] === '-') { - console.log(id, id[id.length - 4]); return `chunk-${id[id.length - 4]}`; } } diff --git a/test/cli/index.js b/test/cli/index.js index a94152a4c6a..2d557bebfdd 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -114,7 +114,7 @@ runTestSuiteWithSamples( childProcess.stderr.on('data', data => { if (config.abortOnStderr && config.abortOnStderr(data)) { - childProcess.kill('SIGINT'); + childProcess.kill(); } }); } From 86d597eebe9d73317d445eafc4ed6159b059bef1 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 17 May 2019 12:13:06 +0200 Subject: [PATCH 4/4] Use a timeout to kill on windows --- test/cli/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cli/index.js b/test/cli/index.js index 2d557bebfdd..9aa7f6abc5b 100644 --- a/test/cli/index.js +++ b/test/cli/index.js @@ -25,7 +25,7 @@ runTestSuiteWithSamples( const command = 'node ' + path.resolve(__dirname, '../../bin') + path.sep + config.command; - const childProcess = exec(command, {}, (err, code, stderr) => { + const childProcess = exec(command, { timeout: 2000 }, (err, code, stderr) => { if (err && !err.killed) { if (config.error) { const shouldContinue = config.error(err); @@ -114,7 +114,7 @@ runTestSuiteWithSamples( childProcess.stderr.on('data', data => { if (config.abortOnStderr && config.abortOnStderr(data)) { - childProcess.kill(); + childProcess.kill('SIGINT'); } }); }