From 20ff66914de8fdb4edbe933a0dd6925a10e464ec Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Mon, 28 Jun 2021 07:32:30 -0400 Subject: [PATCH] Exit when stdin closes This is useful for long running processes that are started by other tools like web frameworks. These two lines were taken from the [postcss-cli](https://github.com/postcss/postcss-cli/blob/4be419d4dab07b8982b4bdc04456c02880dbf667/index.js#L55..L56). --- bin/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/main.js b/bin/main.js index a29e512..9cfebdb 100644 --- a/bin/main.js +++ b/bin/main.js @@ -138,6 +138,9 @@ module.exports = function main(source, outDir, args) { } if (args.watch) { + process.stdin.on('end', () => process.exit(0)) + process.stdin.resume() + if (options.initialCopy) { log() log(`Copy: ${source} --> ${outDir}`)