Skip to content

Commit de1beec

Browse files
Timergaearon
authored andcommitted
Stop using npm link in tests (#3345)
* Try a custom function * fix path * install rsync * Test with node 8 * Ensure package is removed from the tree * Remove ours * matching functions * try cygwin * try c:/ * sigh * Try /cygdrive/ * Try /cygdrive/ * Revert "Try /cygdrive/" This reverts commit ab1ed779456d39bedbdb128a7aec3bb88b8eeb1c. * Use sub-optimal copy * Remove rsync install * Fix variable * Continue on err * Don't link react-scripts, lol * run yarn after eject * re-enable cleanup * uninstall yarn * try with force * appveyor ... seriously? * swallow bad eject * remove eject error swallow * Revert "run yarn after eject" This reverts commit eebf1dbc19aeb6e1f66d5ec27bda2d076bea0956. * Run yarn after eject * add a comment
1 parent 345f550 commit de1beec

File tree

3 files changed

+80
-21
lines changed

3 files changed

+80
-21
lines changed

appveyor.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ image: Visual Studio 2017
22

33
environment:
44
matrix:
5-
- nodejs_version: 7
5+
- nodejs_version: 8
66
test_suite: "simple"
7-
- nodejs_version: 7
7+
- nodejs_version: 8
88
test_suite: "installs"
9-
- nodejs_version: 7
9+
- nodejs_version: 8
1010
test_suite: "kitchensink"
1111
- nodejs_version: 6
1212
test_suite: "simple"

tasks/e2e-kitchensink.sh

+41-14
Original file line numberDiff line numberDiff line change
@@ -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.
4873
function exists {
4974
for f in $*; do
@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
162187
cd "$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
174199
REACT_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...
228248
echo 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
241268
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \

tasks/e2e-simple.sh

+36-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ function create_react_app {
4343
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
4444
}
4545

46+
function install_package {
47+
local pkg=$(basename $1)
48+
49+
# Clean target (for safety)
50+
rm -rf node_modules/$pkg/
51+
rm -rf node_modules/**/$pkg/
52+
53+
# Copy package into node_modules/ ignoring installed deps
54+
# rsync -a ${1%/} node_modules/ --exclude node_modules
55+
cp -R ${1%/} node_modules/
56+
rm -rf node_modules/$pkg/node_modules/
57+
58+
# Install `dependencies`
59+
cd node_modules/$pkg/
60+
if [ "$USE_YARN" = "yes" ]
61+
then
62+
yarn install --production
63+
else
64+
npm install --only=production
65+
fi
66+
# Remove our packages to ensure side-by-side versions are used (which we link)
67+
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
68+
cd ../..
69+
}
70+
4671
# Check for the existence of one or more files.
4772
function exists {
4873
for f in $*; do
@@ -306,11 +331,18 @@ verify_module_scope
306331
# Eject...
307332
echo yes | npm run eject
308333

334+
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
335+
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
336+
# this in the near future.
337+
if hash yarnpkg 2>/dev/null
338+
then
339+
yarnpkg install --check-files
340+
fi
341+
309342
# ...but still link to the local packages
310-
npm link "$root_path"/packages/babel-preset-react-app
311-
npm link "$root_path"/packages/eslint-config-react-app
312-
npm link "$root_path"/packages/react-dev-utils
313-
npm link "$root_path"/packages/react-scripts
343+
install_package "$root_path"/packages/babel-preset-react-app
344+
install_package "$root_path"/packages/eslint-config-react-app
345+
install_package "$root_path"/packages/react-dev-utils
314346

315347
# Test the build
316348
npm run build

0 commit comments

Comments
 (0)