Skip to content

Commit f361edb

Browse files
authored
Rewatch: add support for "rescript -w" for compatibility (#7649)
* Add support for "rescript -w" for compatibility * CHANGELOG
1 parent 736159e commit f361edb

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- Clean up `config.ml`. https://github.com/rescript-lang/rescript/pull/7636
2626
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
2727
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
28+
- Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649
2829

2930
#### :rocket: New Feature
3031

rewatch/src/cli.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ pub struct BuildArgs {
107107

108108
#[command(flatten)]
109109
pub snapshot_output: SnapshotOutputArg,
110+
111+
/// Watch mode (deprecated, use `rescript watch` instead)
112+
#[arg(short, default_value_t = false, num_args = 0..=1)]
113+
pub watch: bool,
110114
}
111115

112116
#[derive(Args, Clone, Debug)]
@@ -130,6 +134,19 @@ pub struct WatchArgs {
130134
pub snapshot_output: SnapshotOutputArg,
131135
}
132136

137+
impl From<BuildArgs> for WatchArgs {
138+
fn from(build_args: BuildArgs) -> Self {
139+
Self {
140+
folder: build_args.folder,
141+
filter: build_args.filter,
142+
after_build: build_args.after_build,
143+
create_sourcedirs: build_args.create_sourcedirs,
144+
dev: build_args.dev,
145+
snapshot_output: build_args.snapshot_output,
146+
}
147+
}
148+
}
149+
133150
#[derive(Subcommand, Clone, Debug)]
134151
pub enum Command {
135152
/// Build the project

rewatch/src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ fn main() -> Result<()> {
1717
.target(env_logger::fmt::Target::Stdout)
1818
.init();
1919

20-
let command = args.command.unwrap_or(cli::Command::Build(args.build_args));
20+
let mut command = args.command.unwrap_or(cli::Command::Build(args.build_args));
21+
22+
if let cli::Command::Build(build_args) = &command {
23+
if build_args.watch {
24+
log::warn!("`rescript build -w` is deprecated. Please use `rescript watch` instead.");
25+
command = cli::Command::Watch(build_args.clone().into());
26+
}
27+
}
2128

2229
// The 'normal run' mode will show the 'pretty' formatted progress. But if we turn off the log
2330
// level, we should never show that.
2431
let show_progress = log_level_filter == LevelFilter::Info;
2532

26-
match command.clone() {
33+
match command {
2734
cli::Command::CompilerArgs { path, dev } => {
2835
println!("{}", build::get_compiler_args(Path::new(&path), *dev)?);
2936
std::process::exit(0);

0 commit comments

Comments
 (0)