-
Notifications
You must be signed in to change notification settings - Fork 58
/
run-jetpack-command.sh
executable file
·47 lines (35 loc) · 1.41 KB
/
run-jetpack-command.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -Eeuo pipefail
local_run_script="${GBM_LOCAL_JP_RUN_SCRIPT:-./bin/run-jetpack-command.sh.local}"
if [ -e "$local_run_script" ]
then
source "$local_run_script"
exit 0
fi
# Check if nvm is installed
[ -z "$NVM_DIR" ] && NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
command -v nvm >/dev/null 2>&1 || {
echo "nvm is not installed or cannot be sourced from $NVM_DIR/nvm.sh. Please verify that "'$NVM_DIR'" points to the .nvm directory."
exit 1
}
pushd jetpack
# Set up node requirement for Jetpack
nvm install
# Set up required pnpm version
listed_pnpm_version=$(npx -c 'echo $npm_package_engines_pnpm')
pnpm_version=$(npx semver -c "$listed_pnpm_version")
# Disable `engine-strict` parameter
#
# The `node` version required by Jetpack will be used to install the dependencies. However, we can't
# ensure that the `node` version used by `npm` to check the `engines` parameter is the expected one.
# More information in: https://github.com/wordpress-mobile/gutenberg-mobile/issues/5688
sed -i.bak 's/^engine-strict = true/engine-strict = false/' .npmrc
# npx might prompt to install pnpm at the requested version. Let's just agree and carry on.
( yes || true ) | npx --cache /tmp/empty-cache pnpm@"$pnpm_version" $1
# Revert `engine-strict` parameter back
sed -i.bak 's/^engine-strict = false/engine-strict = true/' .npmrc
rm .npmrc.bak
popd
# Revert to Gutenberg node version
nvm use