@@ -36,6 +36,10 @@ function handle_exit {
36
36
exit
37
37
}
38
38
39
+ function create_react_app {
40
+ node " $temp_cli_path " /node_modules/create-react-app/index.js $*
41
+ }
42
+
39
43
# Exit the script with a helpful error message when any error is encountered
40
44
trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
41
45
@@ -124,7 +128,7 @@ npm install $cli_path
124
128
# Install the app in a temporary location
125
129
temp_app_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_app_path' `
126
130
cd $temp_app_path
127
- node " $temp_cli_path " /node_modules/create-react-app/index.js --scripts-version=$scripts_path test-app
131
+ create_react_app --scripts-version=$scripts_path test-app
128
132
129
133
# ******************************************************************************
130
134
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -178,5 +182,41 @@ npm test -- --watch=no
178
182
# Test the server
179
183
npm start -- --smoke-test
180
184
185
+
186
+ # ******************************************************************************
187
+ # Test --scripts-version is a version number
188
+ # ******************************************************************************
189
+
190
+ cd $temp_app_path
191
+ create_react_app --scripts-version=0.4.0 test-app-version-number
192
+ cd test-app-version-number
193
+
194
+ # Check corresponding scripts version is installed.
195
+ test -e node_modules/react-scripts
196
+ grep ' "version": "0.4.0"' node_modules/react-scripts/package.json
197
+
198
+ # ******************************************************************************
199
+ # Test --scripts-version is a tarball url
200
+ # ******************************************************************************
201
+
202
+ cd $temp_app_path
203
+ create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
204
+ cd test-app-tarball-url
205
+
206
+ # Check corresponding scripts version is installed.
207
+ test -e node_modules/react-scripts
208
+ grep ' "version": "0.4.0"' node_modules/react-scripts/package.json
209
+
210
+ # ******************************************************************************
211
+ # Test --scripts-version is a custom fork of react-scripts
212
+ # ******************************************************************************
213
+
214
+ cd $temp_app_path
215
+ create_react_app --scripts-version=react-scripts-fork test-app-fork
216
+ cd test-app-fork
217
+
218
+ # Check corresponding scripts version is installed.
219
+ test -e node_modules/react-scripts-fork
220
+
181
221
# Cleanup
182
222
cleanup
0 commit comments