@@ -14,8 +14,22 @@ function render(pkg, currentState) {
1414 const rows = [ ] ;
1515
1616 const indent = ' ' + emoji ( ' ' ) ;
17- const flags = currentState . get ( 'global' ) ? '--global' : `--save${ pkg . devDependency ? '-dev' : '' } ` ;
18- const upgradeCommand = `npm install ${ flags } ${ packageName } @${ pkg . latest } ` ;
17+ const installer = currentState . get ( 'installer' ) ;
18+ const isYarn = installer === 'yarn' ;
19+
20+ const args = [ isYarn ? 'add' : 'install' ] ;
21+ if ( currentState . get ( 'global' ) ) {
22+ isYarn ? args . unshift ( 'global' ) : args . push ( '--global' ) ;
23+ }
24+
25+ const flags = [ ] ;
26+ if ( isYarn ) {
27+ pkg . devDependency && flags . push ( '--dev' ) ;
28+ } else {
29+ pkg . devDependency ? flags . push ( '--save-dev' ) : flags . push ( '--save' ) ;
30+ }
31+
32+ const upgradeCommand = `${ installer } ${ args . join ( ' ' ) } ${ packageName } @${ pkg . latest } ${ flags . join ( ' ' ) } ` ;
1933 const upgradeMessage = `${ chalk . green ( upgradeCommand ) } to go from ${ pkg . installed } to ${ pkg . latest } ` ;
2034 // DYLAN: clean this up
2135 const status = _ ( [
@@ -35,7 +49,11 @@ function render(pkg, currentState) {
3549 indent + `Depcheck did not find code similar to ${ chalk . green ( `require('${ packageName } ')` ) } or ${ chalk . green ( `import from '${ packageName } '` ) } .` ,
3650 indent + `Check your code before removing as depcheck isn't able to foresee all ways dependencies can be used.` ,
3751 indent + `Use ${ chalk . green ( '--skip-unused' ) } to skip this check.` ,
38- indent + `To remove this package: ${ chalk . green ( `npm uninstall --save${ pkg . devDependency ? '-dev' : '' } ${ packageName } ` ) } `
52+ indent + `To remove this package: ${ chalk . green (
53+ isYarn
54+ ? `yarn remove ${ packageName } ${ pkg . devDependency ? '--dev' : '' } `
55+ : `npm uninstall ${ packageName } --save${ pkg . devDependency ? '-dev' : '' } `
56+ ) } `
3957 ] : '' ,
4058 pkg . mismatch && ! pkg . bump ? chalk . bgRed . yellow . bold ( emoji ( ' :interrobang: ' ) + ' MISMATCH ' ) + ' Installed version does not match package.json. ' + pkg . installed + ' ≠ ' + pkg . packageJson : '' ,
4159 pkg . regError ? chalk . bgRed . white . bold ( emoji ( ' :no_entry: ' ) + ' NPM ERR! ' ) + ' ' + chalk . red ( pkg . regError ) : ''
0 commit comments