@@ -52,6 +52,7 @@ if (currentNodeVersion.split('.')[0] < 4) {
52
52
process . exit ( 1 ) ;
53
53
}
54
54
55
+ var commander = require ( 'commander' ) ;
55
56
var fs = require ( 'fs-extra' ) ;
56
57
var path = require ( 'path' ) ;
57
58
var execSync = require ( 'child_process' ) . execSync ;
@@ -60,7 +61,7 @@ var semver = require('semver');
60
61
61
62
var projectName ;
62
63
63
- var program = require ( ' commander' )
64
+ var program = commander
64
65
. version ( require ( './package.json' ) . version )
65
66
. arguments ( '<project-directory>' )
66
67
. usage ( chalk . green ( '<project-directory>' ) + ' [options]' )
@@ -69,6 +70,7 @@ var program = require('commander')
69
70
} )
70
71
. option ( '--verbose' , 'print additional logs' )
71
72
. option ( '--scripts-version <alternative-package>' , 'use a non-standard version of react-scripts' )
73
+ . allowUnknownOption ( )
72
74
. on ( '--help' , function ( ) {
73
75
console . log ( ' Only ' + chalk . green ( '<project-directory>' ) + ' is required.' ) ;
74
76
console . log ( ) ;
@@ -82,7 +84,7 @@ var program = require('commander')
82
84
console . log ( ' ' + chalk . cyan ( 'https://github.com/facebookincubator/create-react-app/issues/new' ) ) ;
83
85
console . log ( ) ;
84
86
} )
85
- . parse ( process . argv )
87
+ . parse ( process . argv ) ;
86
88
87
89
if ( typeof projectName === 'undefined' ) {
88
90
console . error ( 'Please specify the project directory:' ) ;
@@ -95,9 +97,14 @@ if (typeof projectName === 'undefined') {
95
97
process . exit ( 1 ) ;
96
98
}
97
99
98
- createApp ( projectName , program . verbose , program . scriptsVersion ) ;
100
+ var hiddenProgram = new commander . Command ( )
101
+ . option ( '--internal-testing-template <path-to-template>' , '(internal usage only, DO NOT RELY ON THIS) ' +
102
+ 'use a non-standard application template' )
103
+ . parse ( process . argv )
104
+
105
+ createApp ( projectName , program . verbose , program . scriptsVersion , hiddenProgram . internalTestingTemplate ) ;
99
106
100
- function createApp ( name , verbose , version ) {
107
+ function createApp ( name , verbose , version , template ) {
101
108
var root = path . resolve ( name ) ;
102
109
var appName = path . basename ( root ) ;
103
110
@@ -130,7 +137,7 @@ function createApp(name, verbose, version) {
130
137
console . log ( 'Installing ' + chalk . cyan ( 'react-scripts' ) + '...' ) ;
131
138
console . log ( ) ;
132
139
133
- run ( root , appName , version , verbose , originalDirectory ) ;
140
+ run ( root , appName , version , verbose , originalDirectory , template ) ;
134
141
}
135
142
136
143
function shouldUseYarn ( ) {
@@ -163,7 +170,7 @@ function install(packageToInstall, verbose, callback) {
163
170
} ) ;
164
171
}
165
172
166
- function run ( root , appName , version , verbose , originalDirectory ) {
173
+ function run ( root , appName , version , verbose , originalDirectory , template ) {
167
174
var packageToInstall = getInstallPackage ( version ) ;
168
175
var packageName = getPackageName ( packageToInstall ) ;
169
176
@@ -183,7 +190,7 @@ function run(root, appName, version, verbose, originalDirectory) {
183
190
'init.js'
184
191
) ;
185
192
var init = require ( scriptsPath ) ;
186
- init ( root , appName , verbose , originalDirectory ) ;
193
+ init ( root , appName , verbose , originalDirectory , template ) ;
187
194
} ) ;
188
195
}
189
196
0 commit comments