File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ const semverDiff = importLazy('semver-diff');
1010const latestVersion = importLazy ( 'latest-version' ) ;
1111const isNpm = importLazy ( 'is-npm' ) ;
1212const isInstalledGlobally = importLazy ( 'is-installed-globally' ) ;
13+ const isYarnGlobal = importLazy ( 'is-yarn-global' ) ;
14+ const hasYarn = importLazy ( 'has-yarn' ) ;
1315const boxen = importLazy ( 'boxen' ) ;
1416const xdgBasedir = importLazy ( 'xdg-basedir' ) ;
1517const isCi = importLazy ( 'is-ci' ) ;
@@ -126,11 +128,22 @@ class UpdateNotifier {
126128
127129 options = {
128130 isGlobal : isInstalledGlobally ( ) ,
131+ isYarnGlobal : isYarnGlobal ( ) ( ) ,
129132 ...options
130133 } ;
131134
135+ let installCommand ;
136+
137+ if ( options . isYarnGlobal ) {
138+ installCommand = `yarn global add ${ this . packageName } ` ;
139+ } else if ( hasYarn ( ) ( ) ) {
140+ installCommand = `yarn add ${ this . packageName } ` ;
141+ } else {
142+ installCommand = `npm i ${ options . isGlobal ? '-g ' : '' } ${ this . packageName } ` ;
143+ }
144+
132145 options . message = options . message || 'Update available ' + chalk ( ) . dim ( this . update . current ) + chalk ( ) . reset ( ' → ' ) +
133- chalk ( ) . green ( this . update . latest ) + ' \nRun ' + chalk ( ) . cyan ( 'npm i ' + ( options . isGlobal ? '-g ' : '' ) + this . packageName ) + ' to update' ;
146+ chalk ( ) . green ( this . update . latest ) + ' \nRun ' + chalk ( ) . cyan ( installCommand ) + ' to update' ;
134147
135148 options . boxenOpts = options . boxenOpts || {
136149 padding : 1 ,
Original file line number Diff line number Diff line change 3636 "boxen" : " ^3.0.0" ,
3737 "chalk" : " ^2.0.1" ,
3838 "configstore" : " ^4.0.0" ,
39+ "has-yarn" : " ^2.1.0" ,
3940 "import-lazy" : " ^2.1.0" ,
4041 "is-ci" : " ^2.0.0" ,
4142 "is-installed-globally" : " ^0.1.0" ,
4243 "is-npm" : " ^3.0.0" ,
44+ "is-yarn-global" : " ^0.3.0" ,
4345 "latest-version" : " ^5.0.0" ,
4446 "semver-diff" : " ^2.0.0" ,
4547 "xdg-basedir" : " ^3.0.0"
You can’t perform that action at this time.
0 commit comments