Npm rework (#199)
This commit is contained in:
@@ -4,6 +4,7 @@ use std::os::unix::fs::MetadataExt;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::utils::require_option;
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use nix::unistd::Uid;
|
use nix::unistd::Uid;
|
||||||
@@ -13,6 +14,7 @@ use tracing::debug;
|
|||||||
use crate::command::CommandExt;
|
use crate::command::CommandExt;
|
||||||
use crate::executor::RunType;
|
use crate::executor::RunType;
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::print_separator;
|
||||||
|
use crate::utils::sudo;
|
||||||
use crate::utils::{require, PathExt};
|
use crate::utils::{require, PathExt};
|
||||||
use crate::{error::SkipStep, execution_context::ExecutionContext};
|
use crate::{error::SkipStep, execution_context::ExecutionContext};
|
||||||
|
|
||||||
@@ -91,11 +93,9 @@ impl NPM {
|
|||||||
fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> {
|
fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> {
|
||||||
let args = ["update", self.global_location_arg()];
|
let args = ["update", self.global_location_arg()];
|
||||||
if use_sudo {
|
if use_sudo {
|
||||||
run_type
|
let sudo_option = sudo();
|
||||||
.execute("sudo")
|
let sudo = require_option(sudo_option, String::from("sudo is not installed"))?;
|
||||||
.arg(&self.command)
|
run_type.execute(sudo).arg(&self.command).args(args).status_checked()?;
|
||||||
.args(args)
|
|
||||||
.status_checked()?;
|
|
||||||
} else {
|
} else {
|
||||||
run_type.execute(&self.command).args(args).status_checked()?;
|
run_type.execute(&self.command).args(args).status_checked()?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user