Skip to content

Commit

Permalink
Merge pull request #805 from reactioncommerce/fix-mohan-804-add-packa…
Browse files Browse the repository at this point in the history
…ge-link-checks

fix: add package link check
  • Loading branch information
delagroove authored Nov 17, 2021
2 parents 7cbf869 + 450bea0 commit 7a03845
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 7a03845

Please sign in to comment.