summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index a7245eba1..b9a298d28 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -155,6 +155,16 @@ Includes versions of Deno, V8 JavaScript Engine, and the TypeScript
compiler.",
),
).subcommand(
+ SubCommand::with_name("bundle")
+ .setting(AppSettings::DisableVersion)
+ .about("Bundle module and dependnecies into single file")
+ .long_about(
+ "Fetch, compile, and output to a single file a module and its dependencies.
+"
+ )
+ .arg(Arg::with_name("source_file").takes_value(true).required(true))
+ .arg(Arg::with_name("out_file").takes_value(true).required(true)),
+ ).subcommand(
SubCommand::with_name("fetch")
.setting(AppSettings::DisableVersion)
.about("Fetch the dependencies")
@@ -436,6 +446,7 @@ const PRETTIER_URL: &str = "https://deno.land/std@v0.7.0/prettier/main.ts";
/// There is no "Help" subcommand because it's handled by `clap::App` itself.
#[derive(Debug, PartialEq)]
pub enum DenoSubcommand {
+ Bundle,
Eval,
Fetch,
Info,
@@ -455,6 +466,13 @@ pub fn flags_from_vec(
let mut flags = parse_flags(&matches.clone());
let subcommand = match matches.subcommand() {
+ ("bundle", Some(bundle_match)) => {
+ flags.allow_write = true;
+ let source_file: &str = bundle_match.value_of("source_file").unwrap();
+ let out_file: &str = bundle_match.value_of("out_file").unwrap();
+ argv.extend(vec![source_file.to_string(), out_file.to_string()]);
+ DenoSubcommand::Bundle
+ }
("eval", Some(eval_match)) => {
flags.allow_net = true;
flags.allow_env = true;
@@ -1034,4 +1052,19 @@ mod tests {
assert_eq!(subcommand, DenoSubcommand::Run);
assert_eq!(argv, svec!["deno", "script.ts"]);
}
+
+ #[test]
+ fn test_flags_from_vec_26() {
+ let (flags, subcommand, argv) =
+ flags_from_vec(svec!["deno", "bundle", "source.ts", "bundle.js"]);
+ assert_eq!(
+ flags,
+ DenoFlags {
+ allow_write: true,
+ ..DenoFlags::default()
+ }
+ );
+ assert_eq!(subcommand, DenoSubcommand::Bundle);
+ assert_eq!(argv, svec!["deno", "source.ts", "bundle.js"])
+ }
}