use push_str instead of multiple calls to arg()

master
Jan Willem Henckel 7 years ago
parent d9d96e8d3b
commit d665ef3a3a
  1. 41
      src/npm.rs

@ -35,29 +35,24 @@ pub fn npm_adduser(
always_auth: bool, always_auth: bool,
auth_type: Option<String>, auth_type: Option<String>,
) -> Result<(), Error> { ) -> Result<(), Error> {
let status = Command::new("npm") let mut args = String::new();
.arg("adduser")
.arg(if let Some(registry) = registry { if let Some(registry) = registry {
format!("--registry {}", registry) args.push_str(&format!(" --registry={}", registry))
} else { }
String::from("") if let Some(scope) = scope {
}) args.push_str(&format!(" --scope={}", scope))
.arg(if let Some(scope) = scope { }
format!("--scope {}", scope)
} else { if always_auth == true {
String::from("") args.push_str(" --always_auth")
}) }
.arg(if always_auth == true {
String::from("--always_auth") if let Some(auth_type) = auth_type {
} else { args.push_str(&format!(" --auth_type={}", auth_type))
String::from("") }
})
.arg(if let Some(auth_type) = auth_type { let status = Command::new("npm").arg("adduser").arg(args).status()?;
format!("--auth_type {}", auth_type)
} else {
String::from("")
})
.status()?;
if !status.success() { if !status.success() {
bail!("Adding registry user account failed"); bail!("Adding registry user account failed");

Loading…
Cancel
Save