Use output instead of status

master
Jan Willem Henckel 7 years ago
parent 4ca46d7f51
commit d1f32c8d6a
  1. 22
      src/npm.rs

@ -1,5 +1,5 @@
use error::Error; use error::Error;
use std::process::Command; use std::process::{Command, Stdio};
pub fn npm_pack(path: &str) -> Result<(), Error> { pub fn npm_pack(path: &str) -> Result<(), Error> {
let pkg_file_path = format!("{}/pkg", path); let pkg_file_path = format!("{}/pkg", path);
@ -38,24 +38,30 @@ pub fn npm_login(
let mut args = String::new(); let mut args = String::new();
if let Some(registry) = registry { if let Some(registry) = registry {
args.push_str(&format!(" --registry={}", registry)) args.push_str(&format!(" --registry={}", registry));
} }
if let Some(scope) = scope { if let Some(scope) = scope {
args.push_str(&format!(" --scope={}", scope)) args.push_str(&format!(" --scope={}", scope));
} }
if always_auth == true { if always_auth == true {
args.push_str(" --always_auth") args.push_str(" --always_auth");
} }
if let Some(auth_type) = auth_type { if let Some(auth_type) = auth_type {
args.push_str(&format!(" --auth_type={}", auth_type)) args.push_str(&format!(" --auth_type={}", auth_type));
} }
let status = Command::new("npm").arg("login").arg(args).status()?; let output = Command::new("npm")
.arg("login")
.arg(args)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.output()?;
if !status.success() { if !output.status.success() {
bail!("Registry user account login failed"); let s = String::from_utf8_lossy(&output.stderr);
Error::cli("Registry user account login failed", s)
} else { } else {
Ok(()) Ok(())
} }

Loading…
Cancel
Save