From 03f3ba5466c8386904fa59ca5598caed58eb7055 Mon Sep 17 00:00:00 2001 From: Steve Hodgkiss Date: Sun, 29 Dec 2024 09:21:32 +1100 Subject: [PATCH] fix(cli): default watchStdin to !process.stdin.isTTY Fixes the issue with running Vite under Elixir and doesn't cause issues when running Vite programmatically [1] [1] https://github.com/vitejs/vite/issues/4079 --- packages/vite/src/node/cli.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index 58aa57db02a3eb..27981ac4004f92 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -169,7 +169,9 @@ cli '--force', `[boolean] force the optimizer to ignore the cache and re-bundle`, ) - .option('--watchStdin', `[boolean] watch stdin and exit on EOF`) + .option('--watchStdin', `[boolean] watch stdin and exit on EOF`, { + default: !process.stdin.isTTY, + }) .action(async (root: string, options: ServerOptions & GlobalCLIOptions) => { filterDuplicateOptions(options) // output structure is preserved even after bundling so require() @@ -365,7 +367,9 @@ cli .option('--strictPort', `[boolean] exit if specified port is already in use`) .option('--open [path]', `[boolean | string] open browser on startup`) .option('--outDir ', `[string] output directory (default: dist)`) - .option('--watchStdin', `[boolean] watch stdin and exit on EOF`) + .option('--watchStdin', `[boolean] watch stdin and exit on EOF`, { + default: !process.stdin.isTTY, + }) .action( async ( root: string,