Skip to content

Commit 44fc8c1

Browse files
committed
end when stdin closed
1 parent f155f32 commit 44fc8c1

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

bin/config-optimist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = function(optimist) {
2424
.string("target").describe("target")
2525
.boolean("cache").describe("cache").default("cache", true)
2626
.boolean("watch").alias("watch", "w").describe("watch")
27+
.boolean("watch-stdin").alias("watch-stdin", "stdin").describe("watch which closes when stdin ends")
2728
.describe("watch-aggregate-timeout")
2829
.describe("watch-poll")
2930
.boolean("hot").alias("hot", "h").describe("hot")

bin/convert-argv.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ module.exports = function(optimist, argv, convertOptions) {
132132
options.watchOptions.poll = true;
133133
}
134134

135+
if(argv["watch-stdin"]) {
136+
options.watchOptions = options.watchOptions || {};
137+
options.watchOptions.stdin = true;
138+
options.watch = true;
139+
}
140+
135141
function processOptions(options) {
136142
function ifArg(name, fn, init, finalize) {
137143
if(Array.isArray(argv[name])) {

bin/webpack.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ function compilerCallback(err, stats) {
167167
if(options.watch) {
168168
var primaryOptions = !Array.isArray(options) ? options : options[0];
169169
var watchOptions = primaryOptions.watchOptions || primaryOptions.watch || {};
170+
if(watchOptions.stdin) {
171+
process.stdin.on('end', function() {
172+
process.exit(0)
173+
});
174+
process.stdin.resume();
175+
}
170176
compiler.watch(watchOptions, compilerCallback);
171177
} else
172178
compiler.run(compilerCallback);

0 commit comments

Comments
 (0)