Skip to content

Commit 4ec5af3

Browse files
viankakrisnagaearon
authored andcommitted
add double quotes to escape spaces in paths in e2e (#1707)
* add double quotes to escape spaces in path * Change $* to "$@" props to @n3tr * escape spaces in path for all e2e tests
1 parent 19a4672 commit 4ec5af3

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

tasks/cra.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ root_path=$PWD
5252
# ******************************************************************************
5353

5454
# Install all our packages
55-
$root_path/node_modules/.bin/lerna bootstrap
55+
"$root_path"/node_modules/.bin/lerna bootstrap
5656

5757
cd packages/react-scripts
5858

@@ -61,10 +61,10 @@ cp package.json package.json.orig
6161

6262
# Replace own dependencies (those in the `packages` dir) with the local paths
6363
# of those packages.
64-
node $root_path/tasks/replace-own-deps.js
64+
node "$root_path"/tasks/replace-own-deps.js
6565

6666
# Finally, pack react-scripts
67-
scripts_path=$root_path/packages/react-scripts/`npm pack`
67+
scripts_path="$root_path"/packages/react-scripts/`npm pack`
6868

6969
# Restore package.json
7070
rm package.json
@@ -79,8 +79,8 @@ mv package.json.orig package.json
7979
yarn cache clean || true
8080

8181
# Go back to the root directory and run the command from here
82-
cd $root_path
83-
node packages/create-react-app/index.js --scripts-version=$scripts_path "$@"
82+
cd "$root_path"
83+
node packages/create-react-app/index.js --scripts-version="$scripts_path" "$@"
8484

8585
# Cleanup
8686
cleanup

tasks/e2e-installs.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
2121

2222
function cleanup {
2323
echo 'Cleaning up.'
24-
cd $root_path
25-
rm -rf $temp_cli_path $temp_app_path
24+
cd "$root_path"
25+
rm -rf "$temp_cli_path" "$temp_app_path"
2626
}
2727

2828
# Error messages are redirected to stderr
@@ -77,18 +77,18 @@ fi
7777
# ******************************************************************************
7878

7979
# Pack CLI
80-
cd $root_path/packages/create-react-app
80+
cd "$root_path"/packages/create-react-app
8181
cli_path=$PWD/`npm pack`
8282

8383
# Install the CLI in a temporary location
84-
cd $temp_cli_path
85-
npm install $cli_path
84+
cd "$temp_cli_path"
85+
npm install "$cli_path"
8686

8787
# ******************************************************************************
8888
# Test --scripts-version with a version number
8989
# ******************************************************************************
9090

91-
cd $temp_app_path
91+
cd "$temp_app_path"
9292
create_react_app --scripts-version=0.4.0 test-app-version-number
9393
cd test-app-version-number
9494

@@ -100,7 +100,7 @@ grep '"version": "0.4.0"' node_modules/react-scripts/package.json
100100
# Test --scripts-version with a tarball url
101101
# ******************************************************************************
102102

103-
cd $temp_app_path
103+
cd "$temp_app_path"
104104
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
105105
cd test-app-tarball-url
106106

@@ -112,7 +112,7 @@ grep '"version": "0.4.0"' node_modules/react-scripts/package.json
112112
# Test --scripts-version with a custom fork of react-scripts
113113
# ******************************************************************************
114114

115-
cd $temp_app_path
115+
cd "$temp_app_path"
116116
create_react_app --scripts-version=react-scripts-fork test-app-fork
117117
cd test-app-fork
118118

@@ -123,7 +123,7 @@ exists node_modules/react-scripts-fork
123123
# Test project folder is deleted on failing package installation
124124
# ******************************************************************************
125125

126-
cd $temp_app_path
126+
cd "$temp_app_path"
127127
# we will install a non-existing package to simulate a failed installataion.
128128
create_react_app --scripts-version=`date +%s` test-app-should-not-exist || true
129129
# confirm that the project folder was deleted
@@ -133,7 +133,7 @@ test ! -d test-app-should-not-exist
133133
# Test project folder is not deleted when creating app over existing folder
134134
# ******************************************************************************
135135

136-
cd $temp_app_path
136+
cd "$temp_app_path"
137137
mkdir test-app-should-remain
138138
echo '## Hello' > ./test-app-should-remain/README.md
139139
# we will install a non-existing package to simulate a failed installataion.
@@ -150,7 +150,7 @@ fi
150150
# ******************************************************************************
151151

152152
#Testing a path that exists
153-
cd $temp_app_path
153+
cd "$temp_app_path"
154154
mkdir test-app-nested-paths-t1
155155
cd test-app-nested-paths-t1
156156
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
@@ -159,13 +159,13 @@ cd test-app-nested-paths-t1/aa/bb/cc/dd
159159
npm start -- --smoke-test
160160

161161
#Testing a path that does not exist
162-
cd $temp_app_path
162+
cd "$temp_app_path"
163163
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
164164
cd test-app-nested-paths-t2/aa/bb/cc/dd
165165
npm start -- --smoke-test
166166

167167
#Testing a path that is half exists
168-
cd $temp_app_path
168+
cd "$temp_app_path"
169169
mkdir -p test-app-nested-paths-t3/aa
170170
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
171171
cd test-app-nested-paths-t3/aa/bb/cc/dd

tasks/e2e-kitchensink.sh

+16-16
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
2222
function cleanup {
2323
echo 'Cleaning up.'
2424
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -s 9
25-
cd $root_path
25+
cd "$root_path"
2626
# TODO: fix "Device or resource busy" and remove ``|| $CI`
27-
rm -rf $temp_cli_path $temp_app_path || $CI
27+
rm -rf "$temp_cli_path" $temp_app_path || $CI
2828
}
2929

3030
# Error messages are redirected to stderr
@@ -42,7 +42,7 @@ function handle_exit {
4242
}
4343

4444
function create_react_app {
45-
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
45+
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
4646
}
4747

4848
# Check for the existence of one or more files.
@@ -79,21 +79,21 @@ fi
7979
# ******************************************************************************
8080

8181
# Pack CLI
82-
cd $root_path/packages/create-react-app
82+
cd "$root_path"/packages/create-react-app
8383
cli_path=$PWD/`npm pack`
8484

8585
# Go to react-scripts
86-
cd $root_path/packages/react-scripts
86+
cd "$root_path"/packages/react-scripts
8787

8888
# Save package.json because we're going to touch it
8989
cp package.json package.json.orig
9090

9191
# Replace own dependencies (those in the `packages` dir) with the local paths
9292
# of those packages.
93-
node $root_path/tasks/replace-own-deps.js
93+
node "$root_path"/tasks/replace-own-deps.js
9494

9595
# Finally, pack react-scripts
96-
scripts_path=$root_path/packages/react-scripts/`npm pack`
96+
scripts_path="$root_path"/packages/react-scripts/`npm pack`
9797

9898
# Restore package.json
9999
rm package.json
@@ -104,12 +104,12 @@ mv package.json.orig package.json
104104
# ******************************************************************************
105105

106106
# Install the CLI in a temporary location
107-
cd $temp_cli_path
108-
npm install $cli_path
107+
cd "$temp_cli_path"
108+
npm install "$cli_path"
109109

110110
# Install the app in a temporary location
111111
cd $temp_app_path
112-
create_react_app --scripts-version=$scripts_path --internal-testing-template=$root_path/packages/react-scripts/fixtures/kitchensink test-kitchensink
112+
create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
113113

114114
# ******************************************************************************
115115
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -120,7 +120,7 @@ create_react_app --scripts-version=$scripts_path --internal-testing-template=$ro
120120
cd test-kitchensink
121121

122122
# Link to our preset
123-
npm link $root_path/packages/babel-preset-react-app
123+
npm link "$root_path"/packages/babel-preset-react-app
124124

125125
# Test the build
126126
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
@@ -172,16 +172,16 @@ E2E_FILE=./build/index.html \
172172
# ******************************************************************************
173173

174174
# Unlink our preset
175-
npm unlink $root_path/packages/babel-preset-react-app
175+
npm unlink "$root_path"/packages/babel-preset-react-app
176176

177177
# Eject...
178178
echo yes | npm run eject
179179

180180
# ...but still link to the local packages
181-
npm link $root_path/packages/babel-preset-react-app
182-
npm link $root_path/packages/eslint-config-react-app
183-
npm link $root_path/packages/react-dev-utils
184-
npm link $root_path/packages/react-scripts
181+
npm link "$root_path"/packages/babel-preset-react-app
182+
npm link "$root_path"/packages/eslint-config-react-app
183+
npm link "$root_path"/packages/react-dev-utils
184+
npm link "$root_path"/packages/react-scripts
185185

186186
# Test the build
187187
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \

tasks/e2e-simple.sh

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
2121

2222
function cleanup {
2323
echo 'Cleaning up.'
24-
cd $root_path
24+
cd "$root_path"
2525
# Uncomment when snapshot testing is enabled by default:
2626
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
27-
rm -rf $temp_cli_path $temp_app_path
27+
rm -rf "$temp_cli_path" $temp_app_path
2828
}
2929

3030
# Error messages are redirected to stderr
@@ -42,7 +42,7 @@ function handle_exit {
4242
}
4343

4444
function create_react_app {
45-
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
45+
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
4646
}
4747

4848
# Check for the existence of one or more files.
@@ -126,21 +126,21 @@ npm start -- --smoke-test
126126
# ******************************************************************************
127127

128128
# Pack CLI
129-
cd $root_path/packages/create-react-app
129+
cd "$root_path"/packages/create-react-app
130130
cli_path=$PWD/`npm pack`
131131

132132
# Go to react-scripts
133-
cd $root_path/packages/react-scripts
133+
cd "$root_path"/packages/react-scripts
134134

135135
# Save package.json because we're going to touch it
136136
cp package.json package.json.orig
137137

138138
# Replace own dependencies (those in the `packages` dir) with the local paths
139139
# of those packages.
140-
node $root_path/tasks/replace-own-deps.js
140+
node "$root_path"/tasks/replace-own-deps.js
141141

142142
# Finally, pack react-scripts
143-
scripts_path=$root_path/packages/react-scripts/`npm pack`
143+
scripts_path="$root_path"/packages/react-scripts/`npm pack`
144144

145145
# Restore package.json
146146
rm package.json
@@ -151,12 +151,12 @@ mv package.json.orig package.json
151151
# ******************************************************************************
152152

153153
# Install the CLI in a temporary location
154-
cd $temp_cli_path
155-
npm install $cli_path
154+
cd "$temp_cli_path"
155+
npm install "$cli_path"
156156

157157
# Install the app in a temporary location
158158
cd $temp_app_path
159-
create_react_app --scripts-version=$scripts_path test-app
159+
create_react_app --scripts-version="$scripts_path" test-app
160160

161161
# ******************************************************************************
162162
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -243,10 +243,10 @@ verify_env_url
243243
echo yes | npm run eject
244244

245245
# ...but still link to the local packages
246-
npm link $root_path/packages/babel-preset-react-app
247-
npm link $root_path/packages/eslint-config-react-app
248-
npm link $root_path/packages/react-dev-utils
249-
npm link $root_path/packages/react-scripts
246+
npm link "$root_path"/packages/babel-preset-react-app
247+
npm link "$root_path"/packages/eslint-config-react-app
248+
npm link "$root_path"/packages/react-dev-utils
249+
npm link "$root_path"/packages/react-scripts
250250

251251
# Test the build
252252
npm run build

tasks/release.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ if [ -n "$(git status --porcelain)" ]; then
3939
exit 1;
4040
fi
4141

42-
cd $root_path
42+
cd "$root_path"
4343
# Go!
4444
./node_modules/.bin/lerna publish --independent "$@"

0 commit comments

Comments
 (0)