Skip to content

Commit 2f62ff8

Browse files
committedSep 2, 2016
Clarify some of the comments
1 parent 6c8713b commit 2f62ff8

File tree

3 files changed

+30
-37
lines changed

3 files changed

+30
-37
lines changed
 

‎tasks/clean_pack.sh

+20-23
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
# LICENSE file in the root directory of this source tree. An additional grant
66
# of patent rights can be found in the PATENTS file in the same directory.
77

8-
# In success case, the only output to stdout is the packagename,
9-
# which might be used by the caller of `tasks/clean_pack.sh`
8+
# This script cleans up the code from blocks only used during local development.
9+
# We call this as part of the `release.sh` script.
10+
# On success, the only output to stdout is the package name.
1011

1112
# Start even if run from root directory
1213
cd "$(dirname "$0")"
1314

14-
# print error messages to stderr
15-
# the cleanup function is optionally defined in caller script
15+
# Print error messages to stderr.
16+
# The calling script may then handle them.
1617
function handle_error {
1718
echo "$(basename $0): \033[31mERROR!\033[m An error was encountered executing \033[36mline $1\033[m." 1>&2;
1819
cleanup
@@ -28,8 +29,8 @@ function handle_exit {
2829

2930
function cleanup {
3031
cd $initial_path
31-
# remove Jest snap test file from local dev project if exists
32-
rm ../template/src/__tests__/__snapshots__/App-test.js.snap
32+
# Uncomment when snapshot testing is enabled by default:
33+
# rm ../template/src/__snapshots__/App.test.js.snap
3334
rm -rf ../$clean_path
3435
}
3536

@@ -39,29 +40,23 @@ trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
3940
# Cleanup before exit on any termination signal
4041
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
4142

42-
# `tasks/clean_pack.sh` the two directories to make sure they are valid npm modules
43-
initial_path=$PWD
44-
4543
# Go to root
44+
initial_path=$PWD
4645
cd ..
47-
# create a temporary clean folder that contains production only code
48-
# do not overwrite any files in the current folder
46+
47+
# Create a temporary clean folder that contains production-only code.
48+
# Do not overwrite any files in the current folder.
4949
clean_path=`mktemp -d clean_XXXX`
5050

51-
# copy files to folder .clean-pack
52-
# `npm publish` looks package.json, if it has a files field, only pack listed files
53-
# follwoing folders, although not listed in the files field, are not copied
54-
# - .git : contains lot of small files
55-
# - $clean_path : the destination folder
56-
# - node_modules : contains lots of small files
57-
# - build : .gitignored folder used in local development
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, and then copy files back.
5854
rsync -av --exclude='.git' --exclude=$clean_path\
59-
--exclude='node_modules' --exclude='build'\
60-
'./' $clean_path >/dev/null
55+
--exclude='node_modules' --exclude='build'\
56+
'./' $clean_path >/dev/null
6157

58+
# Now remove all the code relevant to development of Create React App.
6259
cd $clean_path
63-
64-
# remove dev-only code
6560
files="$(find -L . -name "*.js" -type f)"
6661
for file in $files; do
6762
sed -i.bak '/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d' $file
@@ -71,8 +66,10 @@ done
7166
# Pack!
7267
packname=`npm pack`
7368

74-
# copy package to current folder
69+
# Now we can copy the package back.
7570
cd ..
7671
cp -f $clean_path/$packname ./
7772
cleanup
73+
74+
# Output the package name so `release.sh` can pick it up.
7875
echo $packname

‎tasks/e2e.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ cd global-cli
8181
npm install
8282
cli_path=$PWD/`npm pack`
8383

84-
# Install the cli in a temporary location ( http://unix.stackexchange.com/a/84980 )
84+
# Install the CLI in a temporary location
85+
# http://unix.stackexchange.com/a/84980
8586
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
8687
cd $temp_cli_path
8788
npm install $cli_path

‎tasks/release.sh

+8-13
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,19 @@ if [ -n "$(git status --porcelain)" ]; then
3131
exit 1;
3232
fi
3333

34-
# create a temporary clean folder that contains production only code
35-
# do not overwrite any files in the current folder
34+
# Create a temporary clean folder that contains production only code.
35+
# Do not overwrite any files in the current folder.
3636
clean_path=`mktemp -d clean_XXXX`
3737

38-
# copy files to folder .clean-pack
39-
# `npm publish` looks package.json, if it has a files field, only pack listed files
40-
# follwoing folders, although not listed in the files field, are not copied
41-
# - .git : contains lot of small files
42-
# - $clean_path : the destination folder
43-
# - node_modules : contains lots of small files
44-
# - build : .gitignored folder used in local development
38+
# Copy some of the project files to the temporary folder.
39+
# Exclude folders that definitely won’t be part of the package from processing.
40+
# We will strip the dev-only code there, and then copy files back.
4541
rsync -av --exclude='.git' --exclude=$clean_path\
46-
--exclude='node_modules' --exclude='build'\
47-
'./' '$clean_path' >/dev/null
42+
--exclude='node_modules' --exclude='build'\
43+
'./' '$clean_path' >/dev/null
4844

45+
# Now remove all the code relevant to development of Create React App.
4946
cd $clean_path
50-
51-
# remove dev-only code
5247
files="$(find -L . -name "*.js" -type f)"
5348
for file in $files; do
5449
sed -i.bak '/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d' $file

0 commit comments

Comments
 (0)
Please sign in to comment.