Skip to content

Commit

Permalink
fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Mar 26, 2018
1 parent 2e44182 commit 49c1921
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).

## Next

### Bug Fixes

* Suppress npm update warnings in log output ([#66](https://github.com/oznu/homebridge-config-ui-x/issues/66))

## 3.4.0

### Notable Changes
Expand Down
26 changes: 13 additions & 13 deletions src/pm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PackageManager {
private plugins: Array<any>;
private customPluginPath: string;
private rp: any;
private npm: any;
private npm: Array<string>;
private node: string;
private nsp: string;

Expand Down Expand Up @@ -54,16 +54,16 @@ class PackageManager {
.filter(fs.existsSync);

if (windowsNpmPath.length) {
return windowsNpmPath[0];
return [windowsNpmPath[0], '--no-update-notifier'];
} else {
hb.log(color.red(`ERROR: Cannot find npm binary. You will not be able to manage plugins or update homebridge.`));
hb.log(color.red(`ERROR: You might be able to fix this problem by running: npm install -g npm`));
return 'npm';
hb.error(`ERROR: Cannot find npm binary. You will not be able to manage plugins or update homebridge.`);
hb.error(`ERROR: You might be able to fix this problem by running: npm install -g npm`);
}
} else {
// Linux and macOS don't require the full path to npm
return 'npm';

}

// Linux and macOS don't require the full path to npm
return ['npm', '--no-update-notifier'];
}

getBasePaths() {
Expand Down Expand Up @@ -97,7 +97,7 @@ class PackageManager {
} else {
paths.push('/usr/local/lib/node_modules');
paths.push('/usr/lib/node_modules');
paths.push(childProcess.execSync('/bin/echo -n "$(npm -g prefix)/lib/node_modules"').toString('utf8'));
paths.push(childProcess.execSync('/bin/echo -n "$(npm --no-update-notifier -g prefix)/lib/node_modules"').toString('utf8'));
}
}

Expand Down Expand Up @@ -377,7 +377,7 @@ class PackageManager {
installOptions.push('--save');
}

return this.executeCommand([this.npm, 'install', '--unsafe-perm', ...installOptions, `${pkg}@latest`], installPath)
return this.executeCommand([...this.npm, 'install', '--unsafe-perm', ...installOptions, `${pkg}@latest`], installPath)
.then(() => this.runNspScan(pkgPath));
})
.catch((err) => {
Expand Down Expand Up @@ -406,7 +406,7 @@ class PackageManager {
installOptions.push('--save');
}

return this.executeCommand([this.npm, 'uninstall', '--unsafe-perm', ...installOptions, pkg], installPath);
return this.executeCommand([...this.npm, 'uninstall', '--unsafe-perm', ...installOptions, pkg], installPath);
})
.catch((err) => {
this.wssBroadcast(color.red(`\n\r${err}\n\r`));
Expand Down Expand Up @@ -437,7 +437,7 @@ class PackageManager {
installOptions.push('--save');
}

return this.executeCommand([this.npm, 'install', '--unsafe-perm', ...installOptions, `${pkg}@latest`], installPath)
return this.executeCommand([...this.npm, 'install', '--unsafe-perm', ...installOptions, `${pkg}@latest`], installPath)
.then(() => this.runNspScan(pkgPath));
})
.catch((err) => {
Expand All @@ -463,7 +463,7 @@ class PackageManager {
.map(installPath => {
hb.log(`Using npm to upgrade homebridge at ${installPath}...`);
const pkg = hb.homebridgeFork ? hb.homebridgeFork : `${hb.homebridgeNpmPkg}@latest`;
return this.executeCommand([this.npm, 'install', '--unsafe-perm', pkg], installPath)
return this.executeCommand([...this.npm, 'install', '--unsafe-perm', pkg], installPath)
.then(() => {
hb.log(`Upgraded homebridge using npm at ${installPath}`);
});
Expand Down

0 comments on commit 49c1921

Please sign in to comment.