From f21ba9d49564a9202514cd85c5ab11b351d719e3 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Fri, 14 Jan 2022 22:46:10 +0200 Subject: [PATCH] Don't print the NPM separator if the step is skipped (fix #831) --- src/steps/node.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/steps/node.rs b/src/steps/node.rs index e1cfddf5..8224a154 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -1,18 +1,20 @@ #![allow(unused_imports)] -use crate::executor::{CommandExt, RunType}; -use crate::terminal::print_separator; -use crate::utils::{require, PathExt}; -use crate::{error::SkipStep, execution_context::ExecutionContext}; +#[cfg(unix)] +use std::os::unix::prelude::MetadataExt; +use std::path::PathBuf; +use std::process::Command; + use anyhow::Result; use directories::BaseDirs; use log::debug; #[cfg(unix)] use nix::unistd::Uid; -#[cfg(unix)] -use std::os::unix::prelude::MetadataExt; -use std::path::PathBuf; -use std::process::Command; + +use crate::executor::{CommandExt, RunType}; +use crate::terminal::print_separator; +use crate::utils::{require, PathExt}; +use crate::{error::SkipStep, execution_context::ExecutionContext}; #[allow(clippy::upper_case_acronyms)] struct NPM { @@ -33,6 +35,8 @@ impl NPM { } fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { + print_separator("Node Package Manager"); + if use_sudo { run_type .execute("sudo") @@ -77,7 +81,6 @@ fn should_use_sudo(npm: &NPM, ctx: &ExecutionContext) -> Result { pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> { let npm = require("npm").map(NPM::new)?; - print_separator("Node Package Manager"); #[cfg(target_os = "linux")] { npm.upgrade(ctx.run_type(), should_use_sudo(&npm, ctx)?)