From 8f98838cddd45a8937856a0bf392b93c1e2faa23 Mon Sep 17 00:00:00 2001 From: Timmo Verlaan Date: Thu, 12 Nov 2020 16:20:05 +0100 Subject: [PATCH] test for exiting watch process with EOF / Ctrl-D --- test/watch.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/watch.js b/test/watch.js index b5bce40..a4df11b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -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') @@ -285,3 +285,14 @@ 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('exit', () => t.end()) + cp.stdin.end() +})