Skip to content

Commit

Permalink
Fix regression with watch cli opt, add tests for this case
Browse files Browse the repository at this point in the history
  • Loading branch information
malstoun committed Jan 17, 2017
1 parent 0b47602 commit 0ec7de9
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bin/webpack.js
Expand Up @@ -344,8 +344,8 @@ function processOptions(options) {
});
}
}
if(firstOptions.watch) {
var watchOptions = firstOptions.watchOptions || firstOptions.watch || {};
if(firstOptions.watch || options.watch) {
var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
if(watchOptions.stdin) {
process.stdin.on("end", function() {
process.exit(0); // eslint-disable-line
Expand Down
2 changes: 1 addition & 1 deletion test/BinTestCases.test.js
Expand Up @@ -93,7 +93,7 @@ describe("BinTestCases", function() {

setTimeout(() => {
if(env.code) {
done(env.error)
done(`Watch didn't run ${env.error}`)
}

const stdout = convertToArrayOfLines(env.stdout);
Expand Down
Empty file.
1 change: 1 addition & 0 deletions test/binCases/watch/multi-config-watch-opt/index.js
@@ -0,0 +1 @@
module.exports = "foo";
1 change: 1 addition & 0 deletions test/binCases/watch/multi-config-watch-opt/index2.js
@@ -0,0 +1 @@
module.exports = "bar";
10 changes: 10 additions & 0 deletions test/binCases/watch/multi-config-watch-opt/test.js
@@ -0,0 +1,10 @@
"use strict";

module.exports = function testAssertions(stdout, stderr, done) {
stdout.should.be.ok();
stdout[0].should.containEql("");
stdout[1].should.containEql("Webpack is watching the files…");

stderr.should.be.empty();
done();
};
1 change: 1 addition & 0 deletions test/binCases/watch/multi-config-watch-opt/test.opts
@@ -0,0 +1 @@
--watch
10 changes: 10 additions & 0 deletions test/binCases/watch/multi-config-watch-opt/webpack.config.js
@@ -0,0 +1,10 @@
var path = require("path");

module.exports = [
{
entry: path.resolve(__dirname, "./index")
},
{
entry: path.resolve(__dirname, "./index2")
}
];
Empty file.
10 changes: 10 additions & 0 deletions test/binCases/watch/single-config-watch-opt/test.js
@@ -0,0 +1,10 @@
"use strict";

module.exports = function testAssertions(stdout, stderr, done) {
stdout.should.be.ok();
stdout[0].should.containEql("");
stdout[1].should.containEql("Webpack is watching the files…");

stderr.should.be.empty();
done();
};
1 change: 1 addition & 0 deletions test/binCases/watch/single-config-watch-opt/test.opts
@@ -0,0 +1 @@
--watch
5 changes: 5 additions & 0 deletions test/binCases/watch/single-config-watch-opt/webpack.config.js
@@ -0,0 +1,5 @@
var path = require("path");

module.exports = {
entry: path.resolve(__dirname, "./index")
};

0 comments on commit 0ec7de9

Please sign in to comment.