@@ -44,6 +44,31 @@ function create_react_app {
4444 node " $temp_cli_path " /node_modules/create-react-app/index.js " $@ "
4545}
4646
47+ function install_package {
48+ local pkg=$( basename $1 )
49+
50+ # Clean target (for safety)
51+ rm -rf node_modules/$pkg /
52+ rm -rf node_modules/** /$pkg /
53+
54+ # Copy package into node_modules/ ignoring installed deps
55+ # rsync -a ${1%/} node_modules/ --exclude node_modules
56+ cp -R ${1%/ } node_modules/
57+ rm -rf node_modules/$pkg /node_modules/
58+
59+ # Install `dependencies`
60+ cd node_modules/$pkg /
61+ if [ " $USE_YARN " = " yes" ]
62+ then
63+ yarn install --production
64+ else
65+ npm install --only=production
66+ fi
67+ # Remove our packages to ensure side-by-side versions are used (which we link)
68+ rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
69+ cd ../..
70+ }
71+
4772# Check for the existence of one or more files.
4873function exists {
4974 for f in $* ; do
@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
162187cd " $temp_app_path /test-kitchensink"
163188
164189# Link to our preset
165- npm link " $root_path " /packages/babel-preset-react-app
190+ install_package " $root_path " /packages/babel-preset-react-app
166191# Link to error overlay package because now it's a dependency
167192# of react-dev-utils and not react-scripts
168- npm link " $root_path " /packages/react-error-overlay
193+ install_package " $root_path " /packages/react-error-overlay
169194
170195# Link to test module
171- npm link " $temp_module_path /node_modules/test-integrity"
196+ install_package " $temp_module_path /node_modules/test-integrity"
172197
173198# Test the build
174199REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
@@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
219244# Finally, let's check that everything still works after ejecting.
220245# ******************************************************************************
221246
222- # Unlink our preset
223- npm unlink " $root_path " /packages/babel-preset-react-app
224- # Unlink error overlay
225- npm unlink " $root_path " /packages/react-error-overlay
226-
227247# Eject...
228248echo yes | npm run eject
229249
250+ # Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
251+ # after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
252+ # this in the near future.
253+ if hash yarnpkg 2> /dev/null
254+ then
255+ yarn install --check-files
256+ fi
257+
230258# ...but still link to the local packages
231- npm link " $root_path " /packages/babel-preset-react-app
232- npm link " $root_path " /packages/eslint-config-react-app
233- npm link " $root_path " /packages/react-error-overlay
234- npm link " $root_path " /packages/react-dev-utils
235- npm link " $root_path " /packages/react-scripts
259+ install_package " $root_path " /packages/babel-preset-react-app
260+ install_package " $root_path " /packages/eslint-config-react-app
261+ install_package " $root_path " /packages/react-error-overlay
262+ install_package " $root_path " /packages/react-dev-utils
236263
237264# Link to test module
238- npm link " $temp_module_path /node_modules/test-integrity"
265+ install_package " $temp_module_path /node_modules/test-integrity"
239266
240267# Test the build
241268REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
0 commit comments