diff --git a/index.js b/index.js index 615638c..da052ce 100755 --- a/index.js +++ b/index.js @@ -61,7 +61,13 @@ let configFile if (argv.env) process.env.NODE_ENV = argv.env if (argv.config) argv.config = path.resolve(argv.config) -if (argv.watch) { +let { isTTY } = process.stdin + +if (process.env.FORCE_IS_TTY === 'true') { + isTTY = true +} + +if (argv.watch && isTTY) { process.stdin.on('end', () => process.exit(0)) process.stdin.resume() } diff --git a/package.json b/package.json index c39207c..a2e8048 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "postcss-cli", + "name": "@0xradical/postcss-cli", "version": "10.0.0", "description": "CLI for PostCSS", "type": "module", @@ -75,4 +75,4 @@ }, "homepage": "https://github.com/postcss/postcss-cli#readme", "license": "MIT" -} +} \ No newline at end of file diff --git a/test/watch.js b/test/watch.js index 4cd5391..625df1b 100644 --- a/test/watch.js +++ b/test/watch.js @@ -205,6 +205,10 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { const cp = spawn(`./index.js test/fixtures/a.css -o ${tmp()} -w --no-map`, { shell: true, + env: { + ...process.env, + FORCE_IS_TTY: true, + }, }) cp.on('error', t.end) @@ -212,6 +216,7 @@ testCb('--watch does exit on closing stdin (Ctrl-D/EOF)', (t) => { t.is(code, 0) t.end() }) + cp.stdin.end() })