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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions bin/src/run/watch.ts
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
Expand Up @@ -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]}`;
}
}
Expand Down
10 changes: 8 additions & 2 deletions test/cli/index.js
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, { timeout: 2000 }, (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
@@ -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
@@ -0,0 +1 @@
export var foo = 42;
3 changes: 3 additions & 0 deletions test/cli/samples/watch/main.js
@@ -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
@@ -0,0 +1,10 @@
export default {
input: 'main.js',
output: {
file: '_actual.js',
format: 'esm'
},
watch: {
clearScreen: false
}
};