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

Declare processConfigsErr before use #2858

Merged
merged 6 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions bin/src/run/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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({
Expand Down
10 changes: 8 additions & 2 deletions test/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -111,6 +111,12 @@ runTestSuiteWithSamples(
}
}
});

childProcess.stderr.on('data', data => {
if (config.abortOnStderr && config.abortOnStderr(data)) {
childProcess.kill('SIGINT');
}
});
}
);
},
Expand Down
9 changes: 9 additions & 0 deletions test/cli/samples/watch/_config.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
};
Empty file.
1 change: 1 addition & 0 deletions test/cli/samples/watch/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export var foo = 42;
3 changes: 3 additions & 0 deletions test/cli/samples/watch/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { foo } from './foo.js';

assert.equal( foo, 42 );
10 changes: 10 additions & 0 deletions test/cli/samples/watch/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
input: 'main.js',
output: {
file: '_actual.js',
format: 'esm'
},
watch: {
clearScreen: false
}
};