Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ let configFile
if (argv.env) process.env.NODE_ENV = argv.env
if (argv.config) argv.config = path.resolve(argv.config)

if (argv.watch) {
let { isTTY } = process.stdin

if (process.env.FORCE_IS_TTY === 'true') {
isTTY = true
}

if (argv.watch && isTTY) {
process.stdin.on('end', () => process.exit(0))
process.stdin.resume()
}
Expand Down
5 changes: 5 additions & 0 deletions test/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,18 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => {

const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, {
shell: true,
env: {
...process.env,
FORCE_IS_TTY: true,
},
})

cp.on('error', t.end)
cp.on('exit', (code) => {
t.is(code, 0)
t.end()
})

cp.stdin.end()
})

Expand Down