@@ -81,11 +81,13 @@ install.runInstall = function (installer, paths, options, cb) {
81
81
* @param {Object } [options]
82
82
* @param {Boolean } [options.npm=true] - whether to run `npm install`
83
83
* @param {Boolean } [options.bower=true] - whether to run `bower install`
84
+ * @param {Boolean } [options.yarn=false] - whether to run `yarn install`
84
85
* @param {Boolean } [options.skipMessage=false] - whether to log the used commands
85
86
* @param {Function } [options.callback] - call once all commands have run
86
87
*/
87
88
88
89
install . installDependencies = function ( options ) {
90
+ options = options || { } ;
89
91
var commands = [ ] ;
90
92
var msg = {
91
93
commands : [ ] ,
@@ -101,28 +103,28 @@ install.installDependencies = function (options) {
101
103
} ;
102
104
}
103
105
104
- options = _ . defaults ( options || { } , {
105
- bower : true ,
106
- npm : true ,
107
- skipMessage : false ,
108
- callback : function ( ) { }
109
- } ) ;
110
-
111
- if ( options . npm ) {
106
+ if ( options . npm !== false ) {
112
107
msg . commands . push ( 'npm install' ) ;
113
108
commands . push ( function ( cb ) {
114
109
this . npmInstall ( null , null , cb ) ;
115
110
} . bind ( this ) ) ;
116
111
}
117
112
118
- if ( options . bower ) {
113
+ if ( options . yarn === true ) {
114
+ msg . commands . push ( 'yarn install' ) ;
115
+ commands . push ( function ( cb ) {
116
+ this . yarnInstall ( null , null , cb ) ;
117
+ } . bind ( this ) ) ;
118
+ }
119
+
120
+ if ( options . bower !== false ) {
119
121
msg . commands . push ( 'bower install' ) ;
120
122
commands . push ( function ( cb ) {
121
123
this . bowerInstall ( null , null , cb ) ;
122
124
} . bind ( this ) ) ;
123
125
}
124
126
125
- assert ( msg . commands . length , 'installDependencies needs at least one of `npm` or `bower ` to run.' ) ;
127
+ assert ( msg . commands . length , 'installDependencies needs at least one of `npm`, `bower` or `yarn ` to run.' ) ;
126
128
127
129
if ( ! options . skipMessage ) {
128
130
var tplValues = _ . extend ( {
@@ -133,7 +135,7 @@ install.installDependencies = function (options) {
133
135
this . log ( msg . template ( tplValues ) ) ;
134
136
}
135
137
136
- async . parallel ( commands , options . callback ) ;
138
+ async . parallel ( commands , options . callback || _ . noop ) ;
137
139
} ;
138
140
139
141
/**
@@ -163,3 +165,16 @@ install.bowerInstall = function install(cmpnt, options, cb) {
163
165
install . npmInstall = function install ( pkgs , options , cb ) {
164
166
return this . runInstall ( 'npm' , pkgs , options , cb ) ;
165
167
} ;
168
+ /**
169
+ * Receives a list of `packages` and an `options` object to install through npm.
170
+ *
171
+ * The installation will automatically run during the run loop `install` phase.
172
+ *
173
+ * @param {String|Array } [pkgs] Packages to install
174
+ * @param {Object } [options] Options to pass to `child_process.spawn` when invoking npm.
175
+ * @param {Function } [cb]
176
+ */
177
+
178
+ install . yarnInstall = function install ( pkgs , options , cb ) {
179
+ return this . runInstall ( 'yarn' , pkgs , options , cb ) ;
180
+ } ;
5 commit comments
bmatto commentedon Nov 29, 2016
This is stellar 💥 - any timeline on a release 😃 ?
mischah commentedon Nov 29, 2016
Not a timeline though, but we are not far away: https://github.com/yeoman/generator/projects/2 😘
bmatto commentedon Nov 29, 2016
Woah github projects - neato.
lucasbento commentedon Sep 27, 2017
What happens if the user doesn't have
yarn
installed? shouldn't it fallback tonpm
?SBoudrias commentedon Sep 28, 2017
@lucasbento not at the moment, we're tracking this idea in #991 - help welcomed :)