From 8d6eddaa3d19358fa1522207882ff69ed70473c2 Mon Sep 17 00:00:00 2001 From: Timmo Verlaan Date: Thu, 12 Nov 2020 16:41:06 +0100 Subject: [PATCH] test for exiting watch process with EOF / Ctrl-D --- test/watch.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/watch.js b/test/watch.js index b5bce40..da56eef 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,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() +})