summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/flags.rs39
1 files changed, 35 insertions, 4 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 7d05d0c01..d0b8f8465 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -167,7 +167,12 @@ This command has implicit access to all permissions (equivalent to deno run --al
Automatically downloads Prettier dependencies on first run.
- deno fmt --write myfile1.ts myfile2.ts",
+ deno fmt myfile1.ts myfile2.ts",
+ ).arg(
+ Arg::with_name("stdout")
+ .long("stdout")
+ .help("Output formated code to stdout")
+ .takes_value(false),
).arg(
Arg::with_name("files")
.takes_value(true)
@@ -194,7 +199,7 @@ ability to spawn subprocesses.
deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts
# run program with permission to read whitelist files from disk and listen to network
- deno run --allow-net --allow-read=$(pwd) https://deno.land/std/http/file_server.ts
+ deno run --allow-net --allow-read=$(pwd) https://deno.land/std/http/file_server.ts
# run program with all permissions
deno run -A https://deno.land/std/http/file_server.ts",
@@ -456,8 +461,10 @@ pub fn flags_from_vec(
.collect();
argv.extend(files);
- // `deno fmt` writes to the files by default
- argv.push("--write".to_string());
+ if !fmt_match.is_present("stdout") {
+ // `deno fmt` writes to the files by default
+ argv.push("--write".to_string());
+ }
DenoSubcommand::Run
}
@@ -918,4 +925,28 @@ mod tests {
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts"]);
}
+
+ #[test]
+ fn test_flags_from_vec_22() {
+ let (flags, subcommand, argv) = flags_from_vec(svec![
+ "deno",
+ "fmt",
+ "--stdout",
+ "script_1.ts",
+ "script_2.ts"
+ ]);
+ assert_eq!(
+ flags,
+ DenoFlags {
+ allow_write: true,
+ allow_read: true,
+ ..DenoFlags::default()
+ }
+ );
+ assert_eq!(subcommand, DenoSubcommand::Run);
+ assert_eq!(
+ argv,
+ svec!["deno", PRETTIER_URL, "script_1.ts", "script_2.ts"]
+ );
+ }
}