Skip to content

Commit 53672ef

Browse files
hramoskelset
authored andcommitted
Enforce lockfile is kept up to date (#21739)
1 parent 44a3e2f commit 53672ef

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Abort the mission if any command fails
4+
set -e
5+
6+
# Allow the script to be invoked from various environments
7+
if [[ -z "${OVERRIDE_YARN_BINARY}" ]]; then
8+
YARN_BINARY=$(command -v yarn)
9+
else
10+
YARN_BINARY="${OVERRIDE_YARN_BINARY}"
11+
fi
12+
13+
REACT_NATIVE_TEMP_DIR=$(mktemp -d /tmp/react-native-XXXXXXXX)
14+
15+
function cleanup {
16+
set +e
17+
rm -rf "$REACT_NATIVE_TEMP_DIR"
18+
set -e
19+
}
20+
21+
function msg {
22+
echo -e " "
23+
echo -e "\\x1B[36m${1}\\x1B[0m";
24+
echo -e "\\x1B[36m${1//?/=}\\x1B[0m"
25+
}
26+
27+
trap cleanup EXIT
28+
29+
cp -R ./package.json "$REACT_NATIVE_TEMP_DIR"
30+
cp -R ./yarn.lock "$REACT_NATIVE_TEMP_DIR"
31+
pushd "$REACT_NATIVE_TEMP_DIR" >/dev/null
32+
33+
if ! $YARN_BINARY --ignore-scripts --silent --non-interactive --mutex network --frozen-lockfile; then
34+
msg "Yarn validation failed."
35+
echo "This means the package.json and yarn.lock disagree in some way."
36+
echo "Try fixing it by running \`yarn\` and committing the changes."
37+
fi
38+
39+
popd >/dev/null

0 commit comments

Comments
 (0)