Skip the NPM root check in macOS (fix #303)
macOS users install NPM using brew to /usr/local. This directory is writable by the user
This commit is contained in:
@@ -121,7 +121,8 @@ Just run `topgrade`. It will run the following steps:
|
|||||||
* [Voom](https://github.com/airblade/voom)
|
* [Voom](https://github.com/airblade/voom)
|
||||||
* Node
|
* Node
|
||||||
* Run `yarn global update` if yarn is installed.
|
* Run `yarn global update` if yarn is installed.
|
||||||
* Run `npm update -g` if NPM is installed and `npm root -g` is a path inside your home directory.
|
* Run `npm update -g`. In Unix systems other then macOS the step will be
|
||||||
|
performed only if`npm root -g` is a path inside your home directory.
|
||||||
* Run `composer global update` if Composer's home directory is inside the home directory of the
|
* Run `composer global update` if Composer's home directory is inside the home directory of the
|
||||||
user. Run `valet install` after.
|
user. Run `valet install` after.
|
||||||
* Upgrade Atom packages
|
* Upgrade Atom packages
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#![allow(unused_imports)]
|
||||||
use crate::error::SkipStep;
|
use crate::error::SkipStep;
|
||||||
use crate::executor::{CommandExt, RunType};
|
use crate::executor::{CommandExt, RunType};
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::print_separator;
|
||||||
@@ -17,6 +18,7 @@ impl NPM {
|
|||||||
Self { command }
|
Self { command }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
fn root(&self) -> Result<PathBuf> {
|
fn root(&self) -> Result<PathBuf> {
|
||||||
Command::new(&self.command)
|
Command::new(&self.command)
|
||||||
.args(&["root", "-g"])
|
.args(&["root", "-g"])
|
||||||
@@ -31,11 +33,15 @@ impl NPM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_npm_upgrade(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
pub fn run_npm_upgrade(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||||
let npm = require("npm").map(NPM::new)?;
|
let npm = require("npm").map(NPM::new)?;
|
||||||
let npm_root = npm.root()?;
|
|
||||||
if !npm_root.is_descendant_of(base_dirs.home_dir()) {
|
#[cfg(not(target_os = "macos"))]
|
||||||
return Err(SkipStep.into());
|
{
|
||||||
|
let npm_root = npm.root()?;
|
||||||
|
if !npm_root.is_descendant_of(_base_dirs.home_dir()) {
|
||||||
|
return Err(SkipStep.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_separator("Node Package Manager");
|
print_separator("Node Package Manager");
|
||||||
|
|||||||
Reference in New Issue
Block a user