Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login issues #487

Merged
merged 2 commits into from
Jan 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ pub fn npm_login(
always_auth: bool,
auth_type: &Option<String>,
) -> Result<(), failure::Error> {
let mut args = String::new();

args.push_str(&format!("--registry={}", registry));
let mut args = vec![format!("login"), format!("--registry={}", registry)];

if let Some(scope) = scope {
args.push_str(&format!(" --scope={}", scope));
args.push(format!("--scope={}", scope));
}

if always_auth == true {
args.push_str(" --always_auth");
args.push(format!("--always_auth"));
}

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");
cmd.arg("login")
.arg(args)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit());
child::run(log, cmd, "npm login")
.with_context(|_| format!("Login to registry {} failed", registry))?;
Ok(())
cmd.args(args);

info!(log, "Running {:?}", cmd);
match cmd.status()?.success() {
true => Ok(()),
false => bail!("Login to registry {} failed", registry),
}
}