Skip to content

Commit

Permalink
add is-installed-globally
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Jun 26, 2017
1 parent adf7af0 commit 27f29a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const chalk = importLazy('chalk');
const semverDiff = importLazy('semver-diff');
const latestVersion = importLazy('latest-version');
const isNpm = importLazy('is-npm');
const isInstalledGlobally = importLazy('is-installed-globally');
const boxen = importLazy('boxen');
const xdgBasedir = importLazy('xdg-basedir');
const ONE_DAY = 1000 * 60 * 60 * 24;
Expand Down Expand Up @@ -109,7 +110,7 @@ class UpdateNotifier {
return this;
}

opts = Object.assign({isGlobal: true}, opts);
opts = Object.assign({isGlobal: isInstalledGlobally()}, opts);

opts.message = opts.message || 'Update available ' + chalk().dim(this.update.current) + chalk().reset(' → ') +
chalk().green(this.update.latest) + ' \nRun ' + chalk().cyan('npm i ' + (opts.isGlobal ? '-g ' : '') + this.packageName) + ' to update';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"chalk": "^1.0.0",
"configstore": "^3.0.0",
"import-lazy": "^2.1.0",
"is-installed-globally": "^0.1.0",
"is-npm": "^1.0.0",
"latest-version": "^3.0.0",
"semver-diff": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('notify(opts)', () => {

it('should use pretty boxen message by default', () => {
const notifier = new Control();
notifier.notify({defer: false});
notifier.notify({defer: false, isGlobal: true});
assert.equal(stripAnsi(errorLogs), [
'',
'',
Expand Down

0 comments on commit 27f29a2

Please sign in to comment.