From 85f96647a4b30699d6df967d582d94c555ac87eb Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 26 May 2022 20:32:26 +0300 Subject: [PATCH] Don't make pnpm a seperate step (#944) Fixes #938 --- src/config.rs | 1 - src/main.rs | 1 - src/steps/node.rs | 27 ++++++--------------------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/config.rs b/src/config.rs index b7a3b7f4..a211e6b2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -113,7 +113,6 @@ pub enum Step { Pip3, Pkg, Pkgin, - Pnpm, Powershell, Raco, Remotes, diff --git a/src/main.rs b/src/main.rs index 310a7d2e..97987239 100644 --- a/src/main.rs +++ b/src/main.rs @@ -335,7 +335,6 @@ fn run() -> Result<()> { runner.execute(Step::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?; runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?; runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?; - runner.execute(Step::Pnpm, "pnpm", || node::pnpm_global_update(&ctx))?; runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?; runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?; runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?; diff --git a/src/steps/node.rs b/src/steps/node.rs index 8224a154..60ffd2bd 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -19,11 +19,15 @@ use crate::{error::SkipStep, execution_context::ExecutionContext}; #[allow(clippy::upper_case_acronyms)] struct NPM { command: PathBuf, + pnpm: Option, } 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");