diff options
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r-- | cli/tools/installer.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 2d2584f54..cc9b5c696 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -41,8 +41,7 @@ fn validate_name(exec_name: &str) -> Result<(), AnyError> { Ok(()) } else { Err(generic_error(format!( - "Invalid executable name: {}", - exec_name + "Invalid executable name: {exec_name}" ))) } } @@ -53,11 +52,8 @@ fn validate_name(exec_name: &str) -> Result<(), AnyError> { /// A second compatible with git bash / MINGW64 /// Generate batch script to satisfy that. fn generate_executable_file(shim_data: &ShimData) -> Result<(), AnyError> { - let args: Vec<String> = shim_data - .args - .iter() - .map(|c| format!("\"{}\"", c)) - .collect(); + let args: Vec<String> = + shim_data.args.iter().map(|c| format!("\"{c}\"")).collect(); let template = format!( "% generated by deno install %\n@deno {} %*\n", args @@ -122,7 +118,7 @@ fn get_installer_root() -> Result<PathBuf, io::Error> { .ok_or_else(|| { io::Error::new( io::ErrorKind::NotFound, - format!("${} is not defined", home_env_var), + format!("${home_env_var} is not defined"), ) })?; home_path.push(".deno"); @@ -201,7 +197,7 @@ pub fn uninstall(name: String, root: Option<PathBuf>) -> Result<(), AnyError> { } if !removed { - return Err(generic_error(format!("No installation found for {}", name))); + return Err(generic_error(format!("No installation found for {name}"))); } // There might be some extra files to delete @@ -339,7 +335,7 @@ fn resolve_shim_data( Level::Debug => "debug", Level::Info => "info", _ => { - return Err(generic_error(format!("invalid log level {}", log_level))) + return Err(generic_error(format!("invalid log level {log_level}"))) } }; executable_args.push(log_level.to_string()); @@ -388,11 +384,11 @@ fn resolve_shim_data( } if let Some(inspect) = flags.inspect { - executable_args.push(format!("--inspect={}", inspect)); + executable_args.push(format!("--inspect={inspect}")); } if let Some(inspect_brk) = flags.inspect_brk { - executable_args.push(format!("--inspect-brk={}", inspect_brk)); + executable_args.push(format!("--inspect-brk={inspect_brk}")); } if let Some(import_map_path) = &flags.import_map_path { @@ -408,7 +404,7 @@ fn resolve_shim_data( extra_files.push(( copy_path, fs::read_to_string(config_path) - .with_context(|| format!("error reading {}", config_path))?, + .with_context(|| format!("error reading {config_path}"))?, )); } else { executable_args.push("--no-config".to_string()); @@ -1082,13 +1078,11 @@ mod tests { assert!(file_path.exists()); let mut expected_string = format!( - "--import-map '{}' --no-config 'http://localhost:4545/cat.ts'", - import_map_url + "--import-map '{import_map_url}' --no-config 'http://localhost:4545/cat.ts'" ); if cfg!(windows) { expected_string = format!( - "\"--import-map\" \"{}\" \"--no-config\" \"http://localhost:4545/cat.ts\"", - import_map_url + "\"--import-map\" \"{import_map_url}\" \"--no-config\" \"http://localhost:4545/cat.ts\"" ); } |