File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ let configFile
5151if ( argv . env ) process . env . NODE_ENV = argv . env
5252if ( argv . config ) argv . config = path . resolve ( argv . config )
5353
54+ if ( argv . watch ) {
55+ process . stdin . on ( 'end' , ( ) => process . exit ( 0 ) )
56+ process . stdin . resume ( )
57+ }
58+
5459Promise . resolve ( )
5560 . then ( ( ) => {
5661 if ( argv . watch && ! ( argv . output || argv . replace || argv . dir ) ) {
Original file line number Diff line number Diff line change @@ -3,11 +3,12 @@ const test = require('ava')
33
44const fs = require ( 'fs-extra' )
55const path = require ( 'path' )
6- const { exec } = require ( 'child_process' )
6+ const { exec, spawn } = require ( 'child_process' )
77const chokidar = require ( 'chokidar' )
88
99const ENV = require ( './helpers/env.js' )
1010const read = require ( './helpers/read.js' )
11+ const tmp = require ( './helpers/tmp.js' )
1112
1213// XXX: All the tests in this file are skipped on the CI; too flacky there
1314const testCb = process . env . CI ? test . cb . skip : test . cb
@@ -285,3 +286,19 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => {
285286 // Timeout:
286287 setTimeout ( ( ) => t . end ( 'test timeout' ) , 50000 )
287288} )
289+
290+ testCb ( '--watch does exit on closing stdin (Ctrl-D/EOF)' , ( t ) => {
291+ t . plan ( 1 )
292+
293+ const cp = spawn (
294+ `./bin/postcss test/fixtures/a.css -o ${ tmp ( ) } -w --no-map` ,
295+ { shell : true }
296+ )
297+
298+ cp . on ( 'error' , t . end )
299+ cp . on ( 'exit' , ( code ) => {
300+ t . is ( code , 0 )
301+ t . end ( )
302+ } )
303+ cp . stdin . end ( )
304+ } )
You can’t perform that action at this time.
0 commit comments