Skip to content
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Clean up `config.ml`. https://github.com/rescript-lang/rescript/pull/7636
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
- Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649

#### :rocket: New Feature

Expand Down
17 changes: 17 additions & 0 deletions rewatch/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pub struct BuildArgs {

#[command(flatten)]
pub snapshot_output: SnapshotOutputArg,

/// Watch mode (deprecated, use `rescript watch` instead)
#[arg(short, default_value_t = false, num_args = 0..=1)]
pub watch: bool,
}

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

impl From<BuildArgs> for WatchArgs {
fn from(build_args: BuildArgs) -> Self {
Self {
folder: build_args.folder,
filter: build_args.filter,
after_build: build_args.after_build,
create_sourcedirs: build_args.create_sourcedirs,
dev: build_args.dev,
snapshot_output: build_args.snapshot_output,
}
}
}

#[derive(Subcommand, Clone, Debug)]
pub enum Command {
/// Build the project
Expand Down
11 changes: 9 additions & 2 deletions rewatch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ fn main() -> Result<()> {
.target(env_logger::fmt::Target::Stdout)
.init();

let command = args.command.unwrap_or(cli::Command::Build(args.build_args));
let mut command = args.command.unwrap_or(cli::Command::Build(args.build_args));

if let cli::Command::Build(build_args) = &command {
if build_args.watch {
log::warn!("`rescript build -w` is deprecated. Please use `rescript watch` instead.");
command = cli::Command::Watch(build_args.clone().into());
}
}

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

match command.clone() {
match command {
cli::Command::CompilerArgs { path, dev } => {
println!("{}", build::get_compiler_args(Path::new(&path), *dev)?);
std::process::exit(0);
Expand Down