Skip to content

Commit

Permalink
fix(cli): default watchStdin to !process.stdin.isTTY
Browse files Browse the repository at this point in the history
Fixes the issue with running Vite under Elixir and doesn't cause issues
when running Vite programmatically [1]

[1] #4079
  • Loading branch information
stevehodgkiss committed Dec 29, 2024
1 parent 71dafec commit 975e966
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 <dir>', `[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,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ export const serverConfigDefaults = Object.freeze({
host: 'localhost',
https: undefined,
open: false,
watchStdin: !process.stdin.isTTY,
watchStdin: false,
proxy: undefined,
cors: true,
headers: {},
Expand Down

0 comments on commit 975e966

Please sign in to comment.