-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest yarn when installed with yarn #132
Changes from 4 commits
05f5fd5
29ce070
9d7f479
6b3eb00
77238f0
bc85ad1
a1b0024
b52ac34
cbb1ed5
69b459e
5352d8b
a85b59f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,15 +107,24 @@ class UpdateNotifier { | |
}; | ||
}); | ||
} | ||
isYarnGlobal() { | ||
const isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys'; | ||
const yarnPath = isWindows ? path.join('Yarn', 'config', 'global') : path.join('.config', 'yarn', 'global'); | ||
if (process.cwd().includes(yarnPath)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
notify(opts) { | ||
if (!process.stdout.isTTY || isNpm() || !this.update) { | ||
return this; | ||
} | ||
|
||
opts = Object.assign({isGlobal: isInstalledGlobally()}, opts); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sindresorhus I created a package is-yarn-global, it without any |
||
const installCommand = this.isYarnGlobal() ? 'yarn global upgrade ' + this.packageName : 'npm i ' + (opts.isGlobal ? '-g ' : '') + this.packageName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
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'; | ||
chalk().green(this.update.latest) + ' \nRun ' + chalk().cyan(installCommand) + ' to update'; | ||
|
||
opts.boxenOpts = opts.boxenOpts || { | ||
padding: 1, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only be
const isWindows = process.platform === 'win32';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌