mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-30 02:15:52 +08:00
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
This commit is contained in:
@@ -44,6 +44,31 @@ function create_react_app {
|
||||
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
|
||||
}
|
||||
|
||||
function install_package {
|
||||
local pkg=$(basename $1)
|
||||
|
||||
# Clean target (for safety)
|
||||
rm -rf node_modules/$pkg/
|
||||
rm -rf node_modules/**/$pkg/
|
||||
|
||||
# Copy package into node_modules/ ignoring installed deps
|
||||
# rsync -a ${1%/} node_modules/ --exclude node_modules
|
||||
cp -R ${1%/} node_modules/
|
||||
rm -rf node_modules/$pkg/node_modules/
|
||||
|
||||
# Install `dependencies`
|
||||
cd node_modules/$pkg/
|
||||
if [ "$USE_YARN" = "yes" ]
|
||||
then
|
||||
yarn install --production
|
||||
else
|
||||
npm install --only=production
|
||||
fi
|
||||
# Remove our packages to ensure side-by-side versions are used (which we link)
|
||||
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
|
||||
cd ../..
|
||||
}
|
||||
|
||||
# Check for the existence of one or more files.
|
||||
function exists {
|
||||
for f in $*; do
|
||||
@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
|
||||
cd "$temp_app_path/test-kitchensink"
|
||||
|
||||
# Link to our preset
|
||||
npm link "$root_path"/packages/babel-preset-react-app
|
||||
install_package "$root_path"/packages/babel-preset-react-app
|
||||
# Link to error overlay package because now it's a dependency
|
||||
# of react-dev-utils and not react-scripts
|
||||
npm link "$root_path"/packages/react-error-overlay
|
||||
install_package "$root_path"/packages/react-error-overlay
|
||||
|
||||
# Link to test module
|
||||
npm link "$temp_module_path/node_modules/test-integrity"
|
||||
install_package "$temp_module_path/node_modules/test-integrity"
|
||||
|
||||
# Test the build
|
||||
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
|
||||
@@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
|
||||
# Finally, let's check that everything still works after ejecting.
|
||||
# ******************************************************************************
|
||||
|
||||
# Unlink our preset
|
||||
npm unlink "$root_path"/packages/babel-preset-react-app
|
||||
# Unlink error overlay
|
||||
npm unlink "$root_path"/packages/react-error-overlay
|
||||
|
||||
# Eject...
|
||||
echo yes | npm run eject
|
||||
|
||||
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
|
||||
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
|
||||
# this in the near future.
|
||||
if hash yarnpkg 2>/dev/null
|
||||
then
|
||||
yarn install --check-files
|
||||
fi
|
||||
|
||||
# ...but still link to the local packages
|
||||
npm link "$root_path"/packages/babel-preset-react-app
|
||||
npm link "$root_path"/packages/eslint-config-react-app
|
||||
npm link "$root_path"/packages/react-error-overlay
|
||||
npm link "$root_path"/packages/react-dev-utils
|
||||
npm link "$root_path"/packages/react-scripts
|
||||
install_package "$root_path"/packages/babel-preset-react-app
|
||||
install_package "$root_path"/packages/eslint-config-react-app
|
||||
install_package "$root_path"/packages/react-error-overlay
|
||||
install_package "$root_path"/packages/react-dev-utils
|
||||
|
||||
# Link to test module
|
||||
npm link "$temp_module_path/node_modules/test-integrity"
|
||||
install_package "$temp_module_path/node_modules/test-integrity"
|
||||
|
||||
# Test the build
|
||||
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
|
||||
|
||||
Reference in New Issue
Block a user