File tree 2 files changed +16
-1
lines changed
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');
10
10
const latestVersion = importLazy ( 'latest-version' ) ;
11
11
const isNpm = importLazy ( 'is-npm' ) ;
12
12
const isInstalledGlobally = importLazy ( 'is-installed-globally' ) ;
13
+ const isYarnGlobal = importLazy ( 'is-yarn-global' ) ;
14
+ const hasYarn = importLazy ( 'has-yarn' ) ;
13
15
const boxen = importLazy ( 'boxen' ) ;
14
16
const xdgBasedir = importLazy ( 'xdg-basedir' ) ;
15
17
const isCi = importLazy ( 'is-ci' ) ;
@@ -126,11 +128,22 @@ class UpdateNotifier {
126
128
127
129
options = {
128
130
isGlobal : isInstalledGlobally ( ) ,
131
+ isYarnGlobal : isYarnGlobal ( ) ( ) ,
129
132
...options
130
133
} ;
131
134
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
+
132
145
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' ;
134
147
135
148
options . boxenOpts = options . boxenOpts || {
136
149
padding : 1 ,
Original file line number Diff line number Diff line change 36
36
"boxen" : " ^3.0.0" ,
37
37
"chalk" : " ^2.0.1" ,
38
38
"configstore" : " ^4.0.0" ,
39
+ "has-yarn" : " ^2.1.0" ,
39
40
"import-lazy" : " ^2.1.0" ,
40
41
"is-ci" : " ^2.0.0" ,
41
42
"is-installed-globally" : " ^0.1.0" ,
42
43
"is-npm" : " ^3.0.0" ,
44
+ "is-yarn-global" : " ^0.3.0" ,
43
45
"latest-version" : " ^5.0.0" ,
44
46
"semver-diff" : " ^2.0.0" ,
45
47
"xdg-basedir" : " ^3.0.0"
You can’t perform that action at this time.
0 commit comments