Skip to content

Commit 1e1a3cb

Browse files
lpalmesTimer
authored andcommitted
Test for accidental extraneous dependencies (facebook#1825)
* Added test to check for accidental dependencies * Refactored test into a function * Removed non capturing group from grep * Update e2e-installs.sh
1 parent 47a8148 commit 1e1a3cb

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Diff for: tasks/e2e-installs.sh

+25-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ function exists {
4646
done
4747
}
4848

49+
# Check for accidental dependencies in package.json
50+
function checkDependencies {
51+
if ! awk '/"dependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
52+
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
53+
echo "Dependencies are correct"
54+
else
55+
echo "There are extraneous dependencies in package.json"
56+
exit 1
57+
fi
58+
59+
60+
if ! awk '/"devDependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
61+
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
62+
echo "Dev Dependencies are correct"
63+
else
64+
echo "There are extraneous devDependencies in package.json"
65+
exit 1
66+
fi
67+
}
68+
4969
function create_react_app {
5070
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
5171
}
@@ -95,6 +115,7 @@ cd test-app-version-number
95115
# Check corresponding scripts version is installed.
96116
exists node_modules/react-scripts
97117
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
118+
checkDependencies
98119

99120
# ******************************************************************************
100121
# Test --scripts-version with a tarball url
@@ -107,6 +128,7 @@ cd test-app-tarball-url
107128
# Check corresponding scripts version is installed.
108129
exists node_modules/react-scripts
109130
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
131+
checkDependencies
110132

111133
# ******************************************************************************
112134
# Test --scripts-version with a custom fork of react-scripts
@@ -161,7 +183,7 @@ exists node_modules/@enoah_netzach/react-scripts
161183
# Test nested folder path as the project name
162184
# ******************************************************************************
163185

164-
#Testing a path that exists
186+
# Testing a path that exists
165187
cd "$temp_app_path"
166188
mkdir test-app-nested-paths-t1
167189
cd test-app-nested-paths-t1
@@ -170,13 +192,13 @@ create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
170192
cd test-app-nested-paths-t1/aa/bb/cc/dd
171193
npm start -- --smoke-test
172194

173-
#Testing a path that does not exist
195+
# Testing a path that does not exist
174196
cd "$temp_app_path"
175197
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
176198
cd test-app-nested-paths-t2/aa/bb/cc/dd
177199
npm start -- --smoke-test
178200

179-
#Testing a path that is half exists
201+
# Testing a path that is half exists
180202
cd "$temp_app_path"
181203
mkdir -p test-app-nested-paths-t3/aa
182204
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd

0 commit comments

Comments
 (0)