@@ -9,6 +9,7 @@ var path = require('path')
99 , rimraf = require ( 'rimraf' )
1010 , async = require ( 'async' )
1111 , exec = require ( 'child_process' ) . exec
12+ , spawn = require ( 'child_process' ) . spawn
1213 , Promise = require ( 'bluebird' )
1314 , singleSeed = true
1415 , seedsToInstall = [ ]
@@ -58,7 +59,7 @@ program.on('--help', function() {
5859/** Parse CLI Arguments
5960================================*/
6061program . parse ( process . argv ) ;
61- if ( ! program . args [ 0 ] || program . args [ 0 ] . toString ( ) . trim ( ) === '' ) {
62+ if ( ! program . args [ 0 ] || program . args [ 0 ] . toString ( ) . trim ( ) === '' ) {
6263 program . help ( ) ;
6364}
6465
@@ -76,13 +77,16 @@ if (!program.args[ 0 ] || program.args[ 0 ].toString().trim() === '') {
7677 * @api private
7778 */
7879function writeLocalJSON ( projectDir ) {
80+ var configDir = path . resolve ( path . join ( projectDir , 'config' ) ) ;
81+
7982 return new Promise ( function ( resolve , reject ) {
80- var localJSONFile = require ( path . join ( projectDir , 'config' , 'local.example.json' ) ) ;
83+ var localJSONFile = require ( path . join ( configDir , 'local.example.json' ) ) ;
8184
82- utils . info ( [ ' Creating local configuration file config/local.json' , '...' ] . join ( '' ) ) ;
83- utils . running ( 'Creating config/local.json...' ) ;
85+ utils
86+ . info ( ' Creating local configuration file config/local.json...' )
87+ . running ( 'Creating config/local.json...' ) ;
8488
85- fs . writeFile ( path . join ( projectDir , 'config' , ' local.json') , JSON . stringify ( localJSONFile , null , 2 ) , function ( err ) {
89+ fs . writeFile ( path . join ( configDir , 'local.json' ) , JSON . stringify ( localJSONFile , null , 2 ) , function ( err ) {
8690 if ( ! ! err ) {
8791 return reject ( err ) ;
8892 }
@@ -101,22 +105,34 @@ function writeLocalJSON(projectDir) {
101105 */
102106function installNPMPackages ( projectDir ) {
103107 return new Promise ( function ( resolve , reject ) {
104- utils . info ( [ ' Installing NPM modules...' ] . join ( '' ) ) ;
105- utils . running ( 'Installing NPM modules...' ) ;
106- var proc = exec ( 'npm install --silent' , { cwd : projectDir } , function ( err ) {
107- if ( ! ! err && err . message !== 'Command failed: ' ) {
108- utils . fail ( err ) ;
109- reject ( err ) ;
108+ utils
109+ . info ( ' Installing NPM modules...' )
110+ . running ( 'Installing NPM modules...' ) ;
111+
112+ var args = [ 'install' ]
113+ , opts = { env : process . env , cwd : projectDir } ;
114+
115+ if ( ! ! program . verbose ) {
116+ opts . stdio = 'inherit' ;
117+ } else {
118+ args . push ( '--silent' ) ;
119+ }
120+
121+ var proc = spawn ( 'npm' , args , opts )
122+ , error = '' ;
123+
124+ proc . on ( 'error' , function ( err ) {
125+ error += err ;
126+ } ) ;
127+
128+ proc . on ( 'close' , function ( code ) {
129+ if ( code !== 0 || ! ! error && error !== 'Command failed: ' ) {
130+ utils . fail ( error ) ;
131+ reject ( error ) ;
110132 } else {
111133 resolve ( ) ;
112134 }
113135 } ) ;
114-
115- // Pipe the output of exec if verbose has been specified
116- if ( program . verbose ) {
117- proc . stdout . pipe ( process . stdout ) ;
118- proc . stderr . pipe ( process . stdout ) ;
119- }
120136 } ) ;
121137}
122138
@@ -147,8 +163,10 @@ function setupBackend() {
147163 return reject ( err ) ;
148164 }
149165
150- utils . info ( [ ' Downloading and extracting ' , csPackage . name , '...' ] . join ( '' ) ) ;
151- utils . running ( 'Downloading and extracting...' ) ;
166+ utils
167+ . info ( 'Downloading and extracting ' + csPackage . name + '...' )
168+ . running ( 'Downloading and extracting ' + csPackage . name + '...' ) ;
169+
152170 lib . packages
153171 . get ( csPackage , projectDir )
154172 . then ( function ( ) {
@@ -159,6 +177,14 @@ function setupBackend() {
159177 utils . progress ( ) ;
160178 return installNPMPackages ( projectDir ) ;
161179 } )
180+ . then ( function ( ) {
181+ utils
182+ . info ( ' Installing module dependencies...' , '└── ' )
183+ . running ( 'Installing module dependencies...' )
184+ . progress ( ) ;
185+
186+ return lib . util . dependencies . installPeerDependencies ( projectDir ) ;
187+ } )
162188 . then ( function ( ) {
163189 utils . progress ( ) ;
164190
@@ -546,7 +572,7 @@ async.waterfall(
546572 lib . utils . finishProgress ( ) ;
547573 process . exit ( 0 ) ;
548574 } else {
549- utils . fail ( err ) ;
575+ utils . fail ( err . stack ? ( err + '\n' + err . stack ) : err ) ;
550576 }
551577 }
552578) ;
0 commit comments