Skip to content

Commit 97d0b97

Browse files
timdeschryversindresorhus
authored andcommittedOct 9, 2017
Add is-installed-globally for auto-detection (#114)
1 parent 6008ccf commit 97d0b97

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed
 

‎index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const chalk = importLazy('chalk');
99
const semverDiff = importLazy('semver-diff');
1010
const latestVersion = importLazy('latest-version');
1111
const isNpm = importLazy('is-npm');
12+
const isInstalledGlobally = importLazy('is-installed-globally');
1213
const boxen = importLazy('boxen');
1314
const xdgBasedir = importLazy('xdg-basedir');
1415
const ONE_DAY = 1000 * 60 * 60 * 24;
@@ -109,7 +110,7 @@ class UpdateNotifier {
109110
return this;
110111
}
111112

112-
opts = Object.assign({isGlobal: true}, opts);
113+
opts = Object.assign({isGlobal: isInstalledGlobally()}, opts);
113114

114115
opts.message = opts.message || 'Update available ' + chalk().dim(this.update.current) + chalk().reset(' → ') +
115116
chalk().green(this.update.latest) + ' \nRun ' + chalk().cyan('npm i ' + (opts.isGlobal ? '-g ' : '') + this.packageName) + ' to update';

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"chalk": "^2.0.1",
3838
"configstore": "^3.0.0",
3939
"import-lazy": "^2.1.0",
40+
"is-installed-globally": "^0.1.0",
4041
"is-npm": "^1.0.0",
4142
"latest-version": "^3.0.0",
4243
"semver-diff": "^2.0.0",

‎test/notify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test.afterEach(() => {
4343

4444
test('use pretty boxen message by default', t => {
4545
const notifier = new Control();
46-
notifier.notify({defer: false});
46+
notifier.notify({defer: false, isGlobal: true});
4747

4848
t.is(stripAnsi(errorLogs), `
4949

0 commit comments

Comments
 (0)
Please sign in to comment.