Skip to content

Commit b99b768

Browse files
committed
Fix e2e test
1 parent ec60307 commit b99b768

File tree

3 files changed

+26
-85
lines changed

3 files changed

+26
-85
lines changed

tasks/clean_pack.sh

Lines changed: 0 additions & 75 deletions
This file was deleted.

tasks/e2e.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ cd "$(dirname "$0")"
1111

1212
function cleanup {
1313
echo 'Cleaning up.'
14-
cd $initial_path
14+
cd $root_path
1515
# Uncomment when snapshot testing is enabled by default:
16-
# rm ../template/src/__snapshots__/App.test.js.snap
16+
# rm ./template/src/__snapshots__/App.test.js.snap
1717
rm -rf $temp_cli_path $temp_app_path
1818
}
1919

@@ -40,20 +40,36 @@ trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
4040
# Echo every command being executed
4141
set -x
4242

43-
# `tasks/clean_pack.sh` the two directories to make sure they are valid npm modules
44-
initial_path=$PWD
45-
43+
# Go to root
4644
cd ..
45+
root_path=$PWD
46+
47+
# Create a temporary clean folder that contains production only code.
48+
# Do not overwrite any files in the current folder.
49+
clean_path=`mktemp -d 2>/dev/null || mktemp -d -t 'clean_path'`
50+
51+
# Copy some of the project files to the temporary folder.
52+
# Exclude folders that definitely won’t be part of the package from processing.
53+
# We will strip the dev-only code there, `npm pack`, and copy the package back.
54+
rsync -av --exclude='.git' --exclude=$clean_path\
55+
--exclude='node_modules' --exclude='build'\
56+
'./' $clean_path >/dev/null
57+
cd $clean_path
58+
59+
# Now remove all the code relevant to development of Create React App.
60+
files="$(find -L . -name "*.js" -type f)"
61+
for file in $files; do
62+
sed -i.bak '/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d' $file
63+
rm $file.bak
64+
done
4765

4866
# A hacky way to avoid bundling dependencies.
4967
# Packing with them enabled takes too much memory, and Travis crashes.
50-
# End to end script is meant to run on Travis so it's not a big deal.
51-
# If you run it locally, you'll need to `git checkout -- package.json`.
5268
perl -i -p0e 's/bundledDependencies.*?]/bundledDependencies": []/s' package.json
5369

5470
# Pack react-scripts
5571
npm install
56-
scripts_path=$PWD/`tasks/clean_pack.sh`
72+
scripts_path=$clean_path/`npm pack`
5773

5874
# Lint
5975
./node_modules/.bin/eslint --ignore-path .gitignore ./

tasks/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ clean_path=`mktemp -d 2>/dev/null || mktemp -d -t 'clean_path'`
3838

3939
# Copy some of the project files to the temporary folder.
4040
# Exclude folders that definitely won’t be part of the package from processing.
41-
# We will strip the dev-only code there, and then copy files back.
41+
# We will strip the dev-only code there, and publish from it.
4242
rsync -av --exclude='.git' --exclude=$clean_path\
4343
--exclude='node_modules' --exclude='build'\
4444
'./' $clean_path >/dev/null
45+
cd $clean_path
4546

4647
# Now remove all the code relevant to development of Create React App.
47-
cd $clean_path
4848
files="$(find -L . -name "*.js" -type f)"
4949
for file in $files; do
5050
sed -i.bak '/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d' $file

0 commit comments

Comments
 (0)