@@ -44,6 +44,31 @@ function create_react_app {
44
44
node " $temp_cli_path " /node_modules/create-react-app/index.js " $@ "
45
45
}
46
46
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
+
47
72
# Check for the existence of one or more files.
48
73
function exists {
49
74
for f in $* ; do
@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
162
187
cd " $temp_app_path /test-kitchensink"
163
188
164
189
# Link to our preset
165
- npm link " $root_path " /packages/babel-preset-react-app
190
+ install_package " $root_path " /packages/babel-preset-react-app
166
191
# Link to error overlay package because now it's a dependency
167
192
# 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
169
194
170
195
# Link to test module
171
- npm link " $temp_module_path /node_modules/test-integrity"
196
+ install_package " $temp_module_path /node_modules/test-integrity"
172
197
173
198
# Test the build
174
199
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
@@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
219
244
# Finally, let's check that everything still works after ejecting.
220
245
# ******************************************************************************
221
246
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
-
227
247
# Eject...
228
248
echo yes | npm run eject
229
249
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
+
230
258
# ...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
236
263
237
264
# Link to test module
238
- npm link " $temp_module_path /node_modules/test-integrity"
265
+ install_package " $temp_module_path /node_modules/test-integrity"
239
266
240
267
# Test the build
241
268
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
0 commit comments