Skip to content

Commit

Permalink
test for exiting watch process with EOF / Ctrl-D
Browse files Browse the repository at this point in the history
  • Loading branch information
tverlaan committed Nov 12, 2020
1 parent d79bb8d commit 8d6edda
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/watch.js
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 8d6edda

Please sign in to comment.