Skip to content

Commit

Permalink
Merge 8d6edda into e279de8
Browse files Browse the repository at this point in the history
  • Loading branch information
tverlaan committed Nov 12, 2020
2 parents e279de8 + 8d6edda commit b7f931e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Promise.resolve()
})
.then((results) => {
if (argv.watch) {
process.stdin.on('end', () => process.exit(0))
process.stdin.resume()

const printMessage = () =>
printVerbose(chalk.dim('\nWaiting for file changes...'))
const watcher = chokidar.watch(input.concat(dependencies(results)), {
Expand Down
14 changes: 13 additions & 1 deletion test/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const test = require('ava')

const fs = require('fs-extra')
const path = require('path')
const { exec } = require('child_process')
const { exec, spawn } = require('child_process')
const chokidar = require('chokidar')

const ENV = require('./helpers/env.js')
Expand Down Expand Up @@ -285,3 +285,15 @@ testCb("--watch doesn't exit on CssSyntaxError", (t) => {
// Timeout:
setTimeout(() => t.end('test timeout'), 50000)
})

testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => {
t.plan(0)

const cp = spawn(
`node ${path.resolve('bin/postcss')} -o output.css -w --no-map`,
{ shell: true }
)
cp.on('error', t.end)
cp.on('exit', () => t.end())
cp.stdin.end()
})

0 comments on commit b7f931e

Please sign in to comment.