Skip to content

Commit e4f1b16

Browse files
authored
fix: local-install.sh script only removes dep if it already exists (#116)
1 parent b064fbf commit e4f1b16

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

scripts/local-install.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ set -eo pipefail
1414
## Install js-client-sdk-common changes into a test app
1515
## ./scripts/local-install.sh . ../js-client-sdk && ./scripts/local-install.sh ../js-client-sdk ../test-apps/my-react-app
1616

17-
if ! command -v jq &> /dev/null; then
18-
echo "jq must be installed before using this script"
19-
exit 1
20-
fi
21-
2217
if [[ "$1" = "" || "$2" = "" ]]; then
2318
echo 'usage: local-install.sh <package-to-install-dir> <consuming-app-dir>'
2419
exit 1
@@ -53,14 +48,16 @@ COMPRESSED_PACKAGE="$(tail -1 /tmp/pack.out)"
5348
tar -xzf "${COMPRESSED_PACKAGE}"
5449
rm "${COMPRESSED_PACKAGE}"
5550
mv package "${PACKAGE_DIR}"
56-
PACKAGE_NAME=$(cat ./package.json | jq -r '.name')
51+
PACKAGE_NAME=$(node -p "require('./package.json').name")
5752
popd > /dev/null
5853

5954
### Install local package to target package
6055
pushd "$2" > /dev/null
6156
TARGET_DIR="$(pwd)"
6257
rm -rf node_modules/.cache
63-
yarn remove "${PACKAGE_NAME}"
58+
if [ "$(grep -c '"'"$PACKAGE_NAME"'"' ./package.json)" -gt 0 ]; then
59+
yarn remove "${PACKAGE_NAME}"
60+
fi
6461
yarn add "${PACKAGE_DIR}" --exact
6562
popd > /dev/null
6663

0 commit comments

Comments
 (0)