Skip to content

Commit 7a03845

Browse files
authored
Merge pull request #805 from reactioncommerce/fix-mohan-804-add-package-link-checks
fix: add package link check
2 parents 7cbf869 + 450bea0 commit 7a03845

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

bin/package-link

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ set -o pipefail # don't ignore exit codes when piping output
1010
set -o posix # more strict failures in subshells
1111
# set -x # enable debugging
1212

13-
IFS="$(printf "\n\t")"
1413
# ---- End unofficial bash strict mode boilerplate
1514

1615
package_name=$1
@@ -19,6 +18,20 @@ yalc_packages_file_name="yalc-packages"
1918
container_id="$(docker-compose ps -q web)"
2019
container_copied_packages_path="/home/node/copied-packages"
2120

21+
# validate input
22+
IFS='/'
23+
read -a pkgarr <<< "$1"
24+
org_name=${pkgarr[0]}
25+
26+
#check if the organization name is valid by cross referencing with node_modules
27+
is_package=$(find node_modules -type d -name $org_name)
28+
if [ -z "$is_package" ]; then
29+
echo "$org_name does not exist"
30+
exit 0
31+
fi
32+
33+
IFS="$(printf "\n\t")"
34+
2235
if [[ -z "${package_name}" ]]; then
2336
if ! [[ -f "$yalc_packages_file_name" ]]; then
2437
echo "Yalc packages file doesn't exist. Creating..."

bin/package-unlink

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@ set -o pipefail # don't ignore exit codes when piping output
1010
set -o posix # more strict failures in subshells
1111
# set -x # enable debugging
1212

13-
IFS="$(printf "\n\t")"
1413
# ---- End unofficial bash strict mode boilerplate
1514

1615
package_name=$1
1716

17+
# validate input
18+
IFS='/'
19+
read -a pkgarr <<< "$1"
20+
org_name=${pkgarr[0]}
21+
22+
#check if the organization name is valid by cross referencing with node_modules
23+
is_package=$(find node_modules -type d -name $org_name)
24+
if [ -z "$is_package" ]; then
25+
echo "$org_name does not exist"
26+
exit 0
27+
fi
28+
29+
IFS="$(printf "\n\t")"
30+
1831
# Unlink the yalc dependency, remove the package drectory and npm install
1932
echo "Unlinking package from Example Storefront..."
2033
docker-compose exec web sh -c "cd /usr/local/src/app && yalc remove ${package_name}"

0 commit comments

Comments
 (0)