@@ -36,6 +36,10 @@ function handle_exit {
3636 exit
3737}
3838
39+ function create_react_app {
40+ node " $temp_cli_path " /node_modules/create-react-app/index.js $*
41+ }
42+
3943# Exit the script with a helpful error message when any error is encountered
4044trap ' set +x; handle_error $LINENO $BASH_COMMAND' ERR
4145
@@ -124,7 +128,7 @@ npm install $cli_path
124128# Install the app in a temporary location
125129temp_app_path=` mktemp -d 2> /dev/null || mktemp -d -t ' temp_app_path' `
126130cd $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
128132
129133# ******************************************************************************
130134# Now that we used create-react-app to create an app depending on react-scripts,
@@ -178,5 +182,41 @@ npm test -- --watch=no
178182# Test the server
179183npm start -- --smoke-test
180184
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+
181221# Cleanup
182222cleanup
0 commit comments