Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/watch-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ tsx watch --exclude "./data/**/*" ./file.ts

- Press <kbd>Return</kbd> to manually rerun the script.
- Use `--clear-screen=false` to prevent the screen from clearing on rerun.
- Use `--reload-on-keypress=false` to disable reloading on keypress. If your child process uses stdin raw mode, be sure to disable this.
9 changes: 8 additions & 1 deletion src/watch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const flags = {
type: [String],
description: 'Paths & globs to exclude from being watched',
},
reloadOnKeypress: {
type: Boolean,
description: 'Reload on keypress (press Return key to manually rerun). Disable if your process uses stdin raw mode.',
default: true,
},
} as const;

export const watchCommand = command({
Expand Down Expand Up @@ -232,5 +237,7 @@ export const watchCommand = command({
).on('all', reRun);

// On "Return" key
process.stdin.on('data', () => reRun('Return key'));
if (argv.flags.reloadOnKeypress && process.stdin.isTTY) {
process.stdin.on('data', () => reRun('Return key'));
}
});