Skip to content

Commit

Permalink
fix: add package link check
Browse files Browse the repository at this point in the history
Signed-off-by: Mohan Narayana <mohan.narayana@mailchimp.com>
  • Loading branch information
MohanNarayana committed Nov 16, 2021
1 parent 7cbf869 commit 450bea0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion bin/package-link
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set -o pipefail # don't ignore exit codes when piping output
set -o posix # more strict failures in subshells
# set -x # enable debugging

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

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

# validate input
IFS='/'
read -a pkgarr <<< "$1"
org_name=${pkgarr[0]}

#check if the organization name is valid by cross referencing with node_modules
is_package=$(find node_modules -type d -name $org_name)
if [ -z "$is_package" ]; then
echo "$org_name does not exist"
exit 0
fi

IFS="$(printf "\n\t")"

if [[ -z "${package_name}" ]]; then
if ! [[ -f "$yalc_packages_file_name" ]]; then
echo "Yalc packages file doesn't exist. Creating..."
Expand Down
15 changes: 14 additions & 1 deletion bin/package-unlink
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ set -o pipefail # don't ignore exit codes when piping output
set -o posix # more strict failures in subshells
# set -x # enable debugging

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

package_name=$1

# validate input
IFS='/'
read -a pkgarr <<< "$1"
org_name=${pkgarr[0]}

#check if the organization name is valid by cross referencing with node_modules
is_package=$(find node_modules -type d -name $org_name)
if [ -z "$is_package" ]; then
echo "$org_name does not exist"
exit 0
fi

IFS="$(printf "\n\t")"

# Unlink the yalc dependency, remove the package drectory and npm install
echo "Unlinking package from Example Storefront..."
docker-compose exec web sh -c "cd /usr/local/src/app && yalc remove ${package_name}"
Expand Down

0 comments on commit 450bea0

Please sign in to comment.