@@ -182,9 +182,9 @@ function install(dependencies, verbose, isOnline) {
182
182
console . log ( ) ;
183
183
console . error ( 'Aborting installation.' , chalk . cyan ( command + ' ' + args . join ( ' ' ) ) , 'has failed.' ) ;
184
184
reject ( ) ;
185
+ return ;
185
186
}
186
-
187
- resolve ( isOnline ) ;
187
+ resolve ( ) ;
188
188
} ) ;
189
189
} ) ;
190
190
}
@@ -203,53 +203,53 @@ function run(root, appName, version, verbose, originalDirectory, template) {
203
203
console . log ( ) ;
204
204
205
205
checkIfOnline ( )
206
- . then ( function ( isOnline ) {
207
- return install ( allDependencies , verbose , isOnline ) ;
208
- } )
209
- . then ( function ( isOnline ) {
210
- checkNodeVersion ( packageName ) ;
211
-
212
- // Since react-scripts has been installed with --save
213
- // we need to move it into devDependencies and rewrite package.json
214
- // also ensure react dependencies have caret version range
215
- fixDependencies ( packageName ) ;
216
-
217
- var scriptsPath = path . resolve (
218
- process . cwd ( ) ,
219
- 'node_modules' ,
220
- packageName ,
221
- 'scripts' ,
222
- 'init.js'
223
- ) ;
224
- var init = require ( scriptsPath ) ;
225
- init ( root , appName , verbose , originalDirectory , template , isOnline ) ;
226
- } )
227
- . catch ( function ( command , args ) {
228
- // On 'exit' we will delete these files from target directory.
229
- var knownGeneratedFiles = [
230
- 'package.json' , 'npm-debug.log' , 'yarn-error.log' , 'yarn-debug.log' , 'node_modules'
231
- ] ;
232
- var currentFiles = fs . readdirSync ( path . join ( root ) ) ;
233
- currentFiles . forEach ( function ( file ) {
234
- knownGeneratedFiles . forEach ( function ( fileToMatch ) {
235
- // This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
236
- // and the rest of knownGeneratedFiles.
237
- if ( ( fileToMatch . match ( / .l o g / g) && file . indexOf ( fileToMatch ) === 0 ) || file === fileToMatch ) {
238
- console . log ( 'Deleting generated file...' , chalk . cyan ( file ) ) ;
239
- fs . removeSync ( path . join ( root , file ) ) ;
240
- }
206
+ . then ( function ( isOnline ) {
207
+ return install ( allDependencies , verbose , isOnline ) ;
208
+ } )
209
+ . then ( function ( ) {
210
+ checkNodeVersion ( packageName ) ;
211
+
212
+ // Since react-scripts has been installed with --save
213
+ // we need to move it into devDependencies and rewrite package.json
214
+ // also ensure react dependencies have caret version range
215
+ fixDependencies ( packageName ) ;
216
+
217
+ var scriptsPath = path . resolve (
218
+ process . cwd ( ) ,
219
+ 'node_modules' ,
220
+ packageName ,
221
+ 'scripts' ,
222
+ 'init.js'
223
+ ) ;
224
+ var init = require ( scriptsPath ) ;
225
+ init ( root , appName , verbose , originalDirectory , template ) ;
226
+ } )
227
+ . catch ( function ( command , args ) {
228
+ // On 'exit' we will delete these files from target directory.
229
+ var knownGeneratedFiles = [
230
+ 'package.json' , 'npm-debug.log' , 'yarn-error.log' , 'yarn-debug.log' , 'node_modules'
231
+ ] ;
232
+ var currentFiles = fs . readdirSync ( path . join ( root ) ) ;
233
+ currentFiles . forEach ( function ( file ) {
234
+ knownGeneratedFiles . forEach ( function ( fileToMatch ) {
235
+ // This will catch `(npm-debug|yarn-error|yarn-debug).log*` files
236
+ // and the rest of knownGeneratedFiles.
237
+ if ( ( fileToMatch . match ( / .l o g / g) && file . indexOf ( fileToMatch ) === 0 ) || file === fileToMatch ) {
238
+ console . log ( 'Deleting generated file...' , chalk . cyan ( file ) ) ;
239
+ fs . removeSync ( path . join ( root , file ) ) ;
240
+ }
241
+ } ) ;
241
242
} ) ;
243
+ var remainingFiles = fs . readdirSync ( path . join ( root ) ) ;
244
+ if ( ! remainingFiles . length ) {
245
+ // Delete target folder if empty
246
+ console . log ( 'Deleting' , chalk . cyan ( appName + '/' ) , 'from' , chalk . cyan ( path . resolve ( root , '..' ) ) ) ;
247
+ process . chdir ( path . resolve ( root , '..' ) ) ;
248
+ fs . removeSync ( path . join ( root ) ) ;
249
+ }
250
+ console . log ( 'Done.' ) ;
251
+ process . exit ( 1 ) ;
242
252
} ) ;
243
- var remainingFiles = fs . readdirSync ( path . join ( root ) ) ;
244
- if ( ! remainingFiles . length ) {
245
- // Delete target folder if empty
246
- console . log ( 'Deleting' , chalk . cyan ( appName + '/' ) , 'from' , chalk . cyan ( path . resolve ( root , '..' ) ) ) ;
247
- process . chdir ( path . resolve ( root , '..' ) ) ;
248
- fs . removeSync ( path . join ( root ) ) ;
249
- }
250
- console . log ( 'Done.' ) ;
251
- process . exit ( 1 ) ;
252
- } ) ;
253
253
}
254
254
255
255
function getInstallPackage ( version ) {
0 commit comments