Merge pull request #487 from danwilhelm/login-issues

Login issues
master
Nick Fitzgerald 6 years ago committed by GitHub
commit 35cabb658f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      src/npm.rs

@ -46,28 +46,28 @@ pub fn npm_login(
always_auth: bool, always_auth: bool,
auth_type: &Option<String>, auth_type: &Option<String>,
) -> Result<(), failure::Error> { ) -> Result<(), failure::Error> {
let mut args = String::new(); let mut args = vec![format!("login"), 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(format!("--scope={}", scope));
} }
if always_auth == true { if always_auth == true {
args.push_str(" --always_auth"); args.push(format!("--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(format!("--auth_type={}", auth_type));
} }
// Interactively ask user for npm login info.
// (child::run does not support interactive input)
let mut cmd = Command::new("npm"); let mut cmd = Command::new("npm");
cmd.arg("login") cmd.args(args);
.arg(args)
.stdin(Stdio::inherit()) info!(log, "Running {:?}", cmd);
.stdout(Stdio::inherit()); match cmd.status()?.success() {
child::run(log, cmd, "npm login") true => Ok(()),
.with_context(|_| format!("Login to registry {} failed", registry))?; false => bail!("Login to registry {} failed", registry),
Ok(()) }
} }

Loading…
Cancel
Save