summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-08-11 23:10:55 +0100
committerGitHub <noreply@github.com>2024-08-12 00:10:55 +0200
commit004b74c8c65a492a15a7538f71d44a92a86675fa (patch)
tree3a6388b688ac084d92dd77b2c81d73117d6adca7
parentb61fd622a5facc0ec29a8c3b04289ff5354ae03f (diff)
feat: Rename --unstable-hmr to --watch-hmr (#24975)
This commit stabilizes HMR functionality and renames `--unstable-hmr` to `--watch-hmr`. The `--unstable-hmr` flag is still working, but hidden from the help output. It will be removed in Deno 2. Once https://github.com/denoland/deno/pull/24958 lands we should improve grouping of `--watch` and `--watch-hmr` flags.
-rw-r--r--cli/args/flags.rs33
-rw-r--r--cli/tools/run/hmr.rs2
-rw-r--r--tests/integration/watcher_tests.rs8
3 files changed, 35 insertions, 8 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index acdcaf8a7..085ba95d8 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -3604,8 +3604,10 @@ fn seed_arg() -> Arg {
fn hmr_arg(takes_files: bool) -> Arg {
let arg = Arg::new("hmr")
- .long("unstable-hmr")
- .help("UNSTABLE: Watch for file changes and hot replace modules")
+ .long("watch-hmr")
+ // NOTE(bartlomieju): compatibility with Deno pre-1.46
+ .alias("unstable-hmr")
+ .help("Watch for file changes and hot replace modules")
.conflicts_with("watch");
if takes_files {
@@ -5252,6 +5254,31 @@ mod tests {
let r = flags_from_vec(svec![
"deno",
"run",
+ "--watch-hmr",
+ "--no-clear-screen",
+ "script.ts"
+ ]);
+ let flags = r.unwrap();
+ assert_eq!(
+ flags,
+ Flags {
+ subcommand: DenoSubcommand::Run(RunFlags {
+ script: "script.ts".to_string(),
+ watch: Some(WatchFlagsWithPaths {
+ hmr: true,
+ paths: vec![],
+ no_clear_screen: true,
+ exclude: vec![],
+ }),
+ }),
+ code_cache_enabled: true,
+ ..Flags::default()
+ }
+ );
+
+ let r = flags_from_vec(svec![
+ "deno",
+ "run",
"--unstable-hmr",
"--no-clear-screen",
"script.ts"
@@ -5277,7 +5304,7 @@ mod tests {
let r = flags_from_vec(svec![
"deno",
"run",
- "--unstable-hmr=foo.txt",
+ "--watch-hmr=foo.txt",
"--no-clear-screen",
"script.ts"
]);
diff --git a/cli/tools/run/hmr.rs b/cli/tools/run/hmr.rs
index 4ca9ee8b9..6ccf8e344 100644
--- a/cli/tools/run/hmr.rs
+++ b/cli/tools/run/hmr.rs
@@ -117,7 +117,7 @@ impl crate::worker::HmrRunner for HmrRunner {
// If after filtering there are no paths it means it's either a file
// we can't HMR or an external file that was passed explicitly to
- // `--unstable-hmr=<file>` path.
+ // `--watch-hmr=<file>` path.
if filtered_paths.is_empty() {
let _ = self.watcher_communicator.force_restart();
continue;
diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs
index bb757eb35..3cec2f442 100644
--- a/tests/integration/watcher_tests.rs
+++ b/tests/integration/watcher_tests.rs
@@ -1675,7 +1675,7 @@ console.log("Listening...")
let mut child = util::deno_cmd()
.current_dir(t.path())
.arg("run")
- .arg("--unstable-hmr")
+ .arg("--watch-hmr")
.arg("--allow-net")
.arg("-L")
.arg("debug")
@@ -1748,7 +1748,7 @@ export function foo() {
let mut child = util::deno_cmd()
.current_dir(t.path())
.arg("run")
- .arg("--unstable-hmr")
+ .arg("--watch-hmr")
.arg("-L")
.arg("debug")
.arg(&file_to_watch)
@@ -1806,7 +1806,7 @@ export function foo() {
let mut child = util::deno_cmd()
.current_dir(t.path())
.arg("run")
- .arg("--unstable-hmr")
+ .arg("--watch-hmr")
.arg("-L")
.arg("debug")
.arg(&file_to_watch)
@@ -1871,7 +1871,7 @@ export function foo() {
let mut child = util::deno_cmd()
.current_dir(t.path())
.arg("run")
- .arg("--unstable-hmr")
+ .arg("--watch-hmr")
.arg("-L")
.arg("debug")
.arg(&file_to_watch)