From 005f7aff7c134f5a49b7b8a0298c5667d340c3fa Mon Sep 17 00:00:00 2001 From: gmanninglive Date: Sat, 4 Jun 2022 11:11:04 +0100 Subject: [PATCH] Add --ignore-stdin flag to cli, this disables stdin listeners --- src/cli.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cli.js b/src/cli.js index c8e8938ea91c..38d6a8be5482 100644 --- a/src/cli.js +++ b/src/cli.js @@ -222,6 +222,11 @@ let commands = { type: Boolean, description: 'Disable autoprefixer', }, + '--ignore-stdin': { + type: Boolean, + description: + 'Disable stdin listeners. Only use in combination with --watch flag.\n\t\t\t For use when running tailwindcss cli as a child process without connection to parent stdin', + }, '-c': '--config', '-i': '--input', '-o': '--output', @@ -418,6 +423,7 @@ async function build() { let shouldPoll = args['--poll'] let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32' let includePostCss = args['--postcss'] + let ignoreStdIn = args['--ignore-stdin'] || false // Polling interval in milliseconds // Used only when polling or coalescing add/change events on Windows @@ -885,9 +891,11 @@ async function build() { } if (shouldWatch) { - /* Abort the watcher if stdin is closed to avoid zombie processes */ - process.stdin.on('end', () => process.exit(0)) - process.stdin.resume() + if (!ignoreStdIn) { + /* Abort the watcher if stdin is closed to avoid zombie processes */ + process.stdin.on('end', () => process.exit(0)) + process.stdin.resume() + } startWatcher() } else { buildOnce()