Skip to content

Commit

Permalink
fix moon fmt call moon tool (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash authored Aug 26, 2024
1 parent f608aa3 commit 552d3f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions crates/moon/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub fn get_err_stdout_with_args_and_replace_dir(
replace_dir(&s, dir)
}

#[track_caller]
fn read(p: &Path) -> String {
std::fs::read_to_string(p).unwrap().replace('\r', "")
}
19 changes: 11 additions & 8 deletions crates/moonbuild/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,17 @@ fn gen_fmt_to_command(graph: &mut n2graph::Graph, item: &FmtItem) -> (Build, Fil

let mut build = Build::new(loc, ins, outs);

let command = CommandBuilder::new("moon")
.arg("tool")
.arg("format-and-diff")
.arg("--old")
.arg(&item.input)
.arg("--new")
.arg(&item.output)
.build();
let command = CommandBuilder::new(
&std::env::current_exe()
.map_or_else(|_| "moon".into(), |x| x.to_string_lossy().into_owned()),
)
.arg("tool")
.arg("format-and-diff")
.arg("--old")
.arg(&item.input)
.arg("--new")
.arg(&item.output)
.build();
build.cmdline = Some(command);

(build, output_id)
Expand Down

0 comments on commit 552d3f6

Please sign in to comment.