summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-10-24 20:22:36 +0100
committerGitHub <noreply@github.com>2024-10-24 21:22:36 +0200
commitea641897c92e3975dd102b31c1419720df358d12 (patch)
tree6962420ad41365010d2cec588bf88e50b874e98d /cli/args
parent5f0bb3c6f4328003012e98ba70ce18e4e2e842de (diff)
fix(fmt): --ext flag requires to pass files (#26525)
To avoid situations like described in https://github.com/denoland/deno/issues/26402 using `deno fmt` with `--ext` flag now requires to explicitly specify list of files (or globs) to format. Closes https://github.com/denoland/deno/issues/26402
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/flags.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 5c2f83561..235dd53a4 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -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")
@@ -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]