Skip to content

Commit

Permalink
fix(fmt): --ext flag requires to pass files (#26525)
Browse files Browse the repository at this point in the history
To avoid situations like described in
#26402
using `deno fmt` with `--ext` flag now requires to explicitly specify
list of files (or globs) to format.

Closes #26402
  • Loading branch information
bartlomieju committed Oct 25, 2024
1 parent f4ef7b0 commit 3d23be1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
"sass", "less", "html", "svelte", "vue", "astro", "yml", "yaml",
"ipynb",
])
.help_heading(FMT_HEADING),
.help_heading(FMT_HEADING).requires("files"),
)
.arg(
Arg::new("ignore")
Expand Down Expand Up @@ -6802,6 +6802,32 @@ mod tests {
..Flags::default()
}
);

let r = flags_from_vec(svec!["deno", "fmt", "--ext", "html"]);
assert!(r.is_err());
let r = flags_from_vec(svec!["deno", "fmt", "--ext", "html", "./**"]);
assert_eq!(
r.unwrap(),
Flags {
subcommand: DenoSubcommand::Fmt(FmtFlags {
check: false,
files: FileFlags {
include: vec!["./**".to_string()],
ignore: vec![],
},
use_tabs: None,
line_width: None,
indent_width: None,
single_quote: None,
prose_wrap: None,
no_semicolons: None,
unstable_component: false,
watch: Default::default(),
}),
ext: Some("html".to_string()),
..Flags::default()
}
);
}

#[test]
Expand Down

0 comments on commit 3d23be1

Please sign in to comment.