9
9
* of patent rights can be found in the PATENTS file in the same directory.
10
10
*/
11
11
12
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13
- // /!\ DO NOT MODIFY THIS FILE /!\
14
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13
+ // /!\ DO NOT MODIFY THIS FILE /!\
14
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
15
//
16
16
// create-react-app is installed globally on people's computers. This means
17
17
// that it is extremely difficult to have them upgrade the version and
21
21
// The only job of create-react-app is to init the repository and then
22
22
// forward all the commands to the local version of create-react-app.
23
23
//
24
- // If you need to add a new command, please add it to local-cli/ .
24
+ // If you need to add a new command, please add it to the scripts/ folder .
25
25
//
26
26
// The only reason to modify this file is to add more warnings and
27
- // troubleshooting information for the `react init ` command.
27
+ // troubleshooting information for the `create- react-app ` command.
28
28
//
29
29
// Do not make breaking changes! We absolutely don't want to have to
30
30
// tell people to update their global version of create-react-app.
31
31
//
32
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
- // /!\ DO NOT MODIFY THIS FILE /!\
34
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
+ // /!\ DO NOT MODIFY THIS FILE /!\
34
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35
35
36
36
'use strict' ;
37
37
@@ -40,18 +40,18 @@ var path = require('path');
40
40
var spawn = require ( 'child_process' ) . spawn ;
41
41
var chalk = require ( 'chalk' ) ;
42
42
var semver = require ( 'semver' ) ;
43
+ var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
44
+
43
45
/**
44
- * Used arguments :
45
- * -v -- version - to print current version of create-react-app and create-react-app-scripts dependency
46
+ * Arguments :
47
+ * -- version - to print current version
46
48
* --verbose - to print logs while init
47
- * --scripts-version <alternative create-react-app-scripts package> - override default (https://registry.npmjs.org/create-react-app-scripts@latest),
48
- * package to install, examples :
49
- * - "0.22.0-rc1" - A new app will be created using a specific version of React CLI from npm repo
50
- * - "https://registry.npmjs.org/create-react-app-scripts/-/create-react-app-scripts-0.20.0.tgz" - a .tgz archive from any npm repo
51
- * - "/Users/home/create-react-app/create-react-app-scripts-0.22.0.tgz" - for package prepared with `npm pack`, useful for e2e tests
49
+ * --scripts-version <alternative package>
50
+ * Example of valid values :
51
+ * - a specific npm version: "0.22.0-rc1"
52
+ * - a .tgz archive from any npm repo: "https://registry.npmjs.org/create-react-app-scripts/-/create-react-app-scripts-0.20.0.tgz"
53
+ * - a package prepared with `npm pack`: "/Users/home/vjeux/ create-react-app/create-react-app-scripts-0.22.0.tgz"
52
54
*/
53
- var argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) ) ;
54
-
55
55
var commands = argv . _ ;
56
56
if ( commands . length === 0 ) {
57
57
console . error (
@@ -60,8 +60,8 @@ if (commands.length === 0) {
60
60
process . exit ( 1 ) ;
61
61
}
62
62
63
- if ( argv . v || argv . version ) {
64
- console . log ( 'create-react-app: ' + require ( './package.json' ) . version ) ;
63
+ if ( argv . version ) {
64
+ console . log ( 'create-react-app version : ' + require ( './package.json' ) . version ) ;
65
65
process . exit ( ) ;
66
66
}
67
67
@@ -70,7 +70,7 @@ createApp(commands[0], argv.verbose, argv['scripts-version']);
70
70
function createApp ( name , verbose , version ) {
71
71
if ( fs . existsSync ( name ) ) {
72
72
console . log ( 'Directory `' + name + '` already exists. Aborting.' ) ;
73
- process . exit ( ) ;
73
+ process . exit ( 1 ) ;
74
74
}
75
75
76
76
var root = path . resolve ( name ) ;
@@ -146,11 +146,12 @@ function checkNodeVersion() {
146
146
if ( ! packageJson . engines || ! packageJson . engines . node ) {
147
147
return ;
148
148
}
149
+
149
150
if ( ! semver . satisfies ( process . version , packageJson . engines . node ) ) {
150
151
console . error (
151
152
chalk . red (
152
- 'You are currently running Node %s but React CLI requires %s. ' +
153
- 'Please use a supported version of Node.\n'
153
+ 'You are currently running Node %s but create-react-app requires %s.' +
154
+ ' Please use a supported version of Node.\n'
154
155
) ,
155
156
process . version ,
156
157
packageJson . engines . node
0 commit comments