diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-12-01 14:11:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 15:11:02 +0100 |
commit | 108972c966d66691c64e90fcdde0584a910b96d5 (patch) | |
tree | 025790ae2719800e64a0d0565274a118b386586a /cli/main.rs | |
parent | 447f3fe410c85e153a518474789682f2accab740 (diff) |
chore(cli/flags): Use deno compile --output for the out file (#8563)
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/cli/main.rs b/cli/main.rs index b4e1f1d2c..916248e4c 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -155,7 +155,7 @@ fn get_types(unstable: bool) -> String { async fn compile_command( flags: Flags, source_file: String, - out_file: Option<String>, + output: Option<PathBuf>, ) -> Result<(), AnyError> { if !flags.unstable { exit_unstable("compile"); @@ -166,14 +166,11 @@ async fn compile_command( let module_specifier = ModuleSpecifier::resolve_url_or_path(&source_file)?; let program_state = ProgramState::new(flags.clone())?; - let out_file = - out_file.or_else(|| infer_name_from_url(module_specifier.as_url())); - let out_file = match out_file { - Some(out_file) => out_file, - None => return Err(generic_error( - "An executable name was not provided. One could not be inferred from the URL. Aborting.", - )), - }; + let output = output.or_else(|| { + infer_name_from_url(module_specifier.as_url()).map(PathBuf::from) + }).ok_or_else(|| generic_error( + "An executable name was not provided. One could not be inferred from the URL. Aborting.", + ))?; let module_graph = create_module_graph_and_maybe_check( module_specifier.clone(), @@ -194,10 +191,10 @@ async fn compile_command( colors::green("Compile"), module_specifier.to_string() ); - create_standalone_binary(bundle_str.as_bytes().to_vec(), out_file.clone()) + create_standalone_binary(bundle_str.as_bytes().to_vec(), output.clone()) .await?; - info!("{} {}", colors::green("Emit"), out_file); + info!("{} {}", colors::green("Emit"), output.display()); Ok(()) } @@ -976,8 +973,8 @@ fn get_subcommand( } DenoSubcommand::Compile { source_file, - out_file, - } => compile_command(flags, source_file, out_file).boxed_local(), + output, + } => compile_command(flags, source_file, output).boxed_local(), DenoSubcommand::Fmt { check, files, |