diff --git a/docs/watch-mode.md b/docs/watch-mode.md index 7e99718aa..9560ac773 100644 --- a/docs/watch-mode.md +++ b/docs/watch-mode.md @@ -39,5 +39,5 @@ tsx watch --ignore "./data/**/*" ./file.ts ## Tips -- Press Return to manually rerun the script. +- Press Return to manually rerun the script. Use `--clear-screen=false` to prevent the screen from clearing on rerun. - Use `--clear-screen=false` to prevent the screen from clearing on rerun. diff --git a/src/watch/index.ts b/src/watch/index.ts index fcc25ac09..ff43bd75a 100644 --- a/src/watch/index.ts +++ b/src/watch/index.ts @@ -36,6 +36,11 @@ const flags = { type: [String], description: 'Paths & globs to exclude from being watched', }, + onReturnKey: { + type: Boolean, + description: 'Trigger re-run on Return key press', + default: true, + }, } as const; export const watchCommand = command({ @@ -216,5 +221,6 @@ export const watchCommand = command({ ).on('all', reRun); // On "Return" key - process.stdin.on('data', () => reRun('Return key')); + if (argv.flags.onReturnKey) + process.stdin.on('data', () => reRun('Return key')); });