Skip to content

Commit 0ec7de9

Browse files
committed
Fix regression with watch cli opt, add tests for this case
1 parent 0b47602 commit 0ec7de9

File tree

12 files changed

+42
-3
lines changed

12 files changed

+42
-3
lines changed

bin/webpack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ function processOptions(options) {
344344
});
345345
}
346346
}
347-
if(firstOptions.watch) {
348-
var watchOptions = firstOptions.watchOptions || firstOptions.watch || {};
347+
if(firstOptions.watch || options.watch) {
348+
var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
349349
if(watchOptions.stdin) {
350350
process.stdin.on("end", function() {
351351
process.exit(0); // eslint-disable-line

test/BinTestCases.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe("BinTestCases", function() {
9393

9494
setTimeout(() => {
9595
if(env.code) {
96-
done(env.error)
96+
done(`Watch didn't run ${env.error}`)
9797
}
9898

9999
const stdout = convertToArrayOfLines(env.stdout);

test/binCases/watch/multi-config-watch-opt/async

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "foo";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "bar";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
module.exports = function testAssertions(stdout, stderr, done) {
4+
stdout.should.be.ok();
5+
stdout[0].should.containEql("");
6+
stdout[1].should.containEql("Webpack is watching the files…");
7+
8+
stderr.should.be.empty();
9+
done();
10+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--watch
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var path = require("path");
2+
3+
module.exports = [
4+
{
5+
entry: path.resolve(__dirname, "./index")
6+
},
7+
{
8+
entry: path.resolve(__dirname, "./index2")
9+
}
10+
];

test/binCases/watch/single-config-watch-opt/async

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
module.exports = function testAssertions(stdout, stderr, done) {
4+
stdout.should.be.ok();
5+
stdout[0].should.containEql("");
6+
stdout[1].should.containEql("Webpack is watching the files…");
7+
8+
stderr.should.be.empty();
9+
done();
10+
};

0 commit comments

Comments
 (0)