From c49e635f88e6bdd990eefd47404405d119d12761 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E9=B9=8F?=
<61752998+iuroc@users.noreply.github.com>
Date: Mon, 19 Aug 2024 18:54:38 +0800
Subject: [PATCH 1/2] Add --on-return-key flag to conditionally enable Return
key listener
---
src/watch/index.ts | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
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'));
});
From 4a101046de355aff1614365bdc344549778ccc25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E9=B9=8F?=
<61752998+iuroc@users.noreply.github.com>
Date: Mon, 19 Aug 2024 18:55:07 +0800
Subject: [PATCH 2/2] Add --on-return-key flag to conditionally enable Return
key listener
---
docs/watch-mode.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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.