@@ -133,10 +133,6 @@ function createApp(name, verbose, version, template) {
133
133
var originalDirectory = process . cwd ( ) ;
134
134
process . chdir ( root ) ;
135
135
136
- console . log ( 'Installing packages. This might take a couple minutes.' ) ;
137
- console . log ( 'Installing ' + chalk . cyan ( 'react, react-dom, react-scripts' ) + '...' ) ;
138
- console . log ( ) ;
139
-
140
136
run ( root , appName , version , verbose , originalDirectory , template ) ;
141
137
}
142
138
@@ -176,6 +172,10 @@ function run(root, appName, version, verbose, originalDirectory, template) {
176
172
177
173
var allDependencies = [ 'react' , 'react-dom' , packageToInstall ] ;
178
174
175
+ console . log ( 'Installing packages. This might take a couple minutes.' ) ;
176
+ console . log ( 'Installing ' + chalk . cyan ( `react, react-dom, ${ packageName } ` ) + '...' ) ;
177
+ console . log ( ) ;
178
+
179
179
install ( allDependencies , verbose , function ( code , command , args ) {
180
180
if ( code !== 0 ) {
181
181
console . error ( chalk . cyan ( command + ' ' + args . join ( ' ' ) ) + ' failed' ) ;
@@ -276,24 +276,29 @@ function checkAppName(appName) {
276
276
277
277
function moveReactScriptsToDev ( packageName ) {
278
278
var packagePath = path . join ( process . cwd ( ) , 'package.json' ) ;
279
- if ( ! fs . existsSync ( packagePath ) ) {
280
- return ;
281
- }
282
-
283
279
var packageJson = require ( packagePath ) ;
280
+
284
281
if ( typeof packageJson . dependencies === 'undefined' ) {
285
- return ;
282
+ console . error (
283
+ chalk . red ( 'Missing dependencies in package.json' )
284
+ ) ;
285
+ process . exit ( 1 ) ;
286
286
}
287
287
288
- var packageVersion = packageJson . dependencies [ packageName ]
289
-
290
- if ( typeof packageVersion !== 'undefined' ) {
291
- packageJson . devDependencies = packageJson . devDependencies || { } ;
292
- packageJson . devDependencies [ packageName ] = packageVersion ;
293
- delete packageJson . dependencies [ packageName ] ;
288
+ var packageVersion = packageJson . dependencies [ packageName ] ;
294
289
295
- fs . writeFileSync ( packagePath , JSON . stringify ( packageJson , null , 2 ) ) ;
290
+ if ( typeof packageVersion === 'undefined' ) {
291
+ console . error (
292
+ chalk . red ( 'Unable to find ' + packageName + ' in package.json' )
293
+ ) ;
294
+ process . exit ( 1 ) ;
296
295
}
296
+
297
+ packageJson . devDependencies = packageJson . devDependencies || { } ;
298
+ packageJson . devDependencies [ packageName ] = packageVersion ;
299
+ delete packageJson . dependencies [ packageName ] ;
300
+
301
+ fs . writeFileSync ( packagePath , JSON . stringify ( packageJson , null , 2 ) ) ;
297
302
}
298
303
299
304
// If project only contains files generated by GH, it’s safe.
0 commit comments