Don't make pnpm a seperate step (#944)

Fixes #938
This commit is contained in:
Roey Darwish Dror
2022-05-26 20:32:26 +03:00
committed by GitHub
parent 23201065c6
commit 85f96647a4
3 changed files with 6 additions and 23 deletions

View File

@@ -19,11 +19,15 @@ use crate::{error::SkipStep, execution_context::ExecutionContext};
#[allow(clippy::upper_case_acronyms)]
struct NPM {
command: PathBuf,
pnpm: Option<PathBuf>,
}
impl NPM {
fn new(command: PathBuf) -> Self {
Self { command }
Self {
command,
pnpm: require("pnpm").ok(),
}
}
#[cfg(target_os = "linux")]
@@ -40,7 +44,7 @@ impl NPM {
if use_sudo {
run_type
.execute("sudo")
.arg(&self.command)
.arg(self.pnpm.as_ref().unwrap_or(&self.command))
.args(&["update", "-g"])
.check_run()?;
} else {
@@ -92,25 +96,6 @@ pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> {
}
}
pub fn pnpm_global_update(ctx: &ExecutionContext) -> Result<()> {
let pnpm = require("pnpm")?;
print_separator("Performant Node Package Manager");
#[cfg(target_os = "linux")]
if should_use_sudo(&require("npm").map(NPM::new)?, ctx)? {
ctx.run_type()
.execute("sudo")
.arg(pnpm)
.args(&["update", "-g"])
.check_run()
} else {
ctx.run_type().execute(&pnpm).args(&["update", "-g"]).check_run()
}
#[cfg(not(target_os = "linux"))]
ctx.run_type().execute(&pnpm).args(&["update", "-g"]).check_run()
}
pub fn deno_upgrade(ctx: &ExecutionContext) -> Result<()> {
let deno = require("deno")?;
let deno_dir = ctx.base_dirs().home_dir().join(".deno");