File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ set -o pipefail # don't ignore exit codes when piping output
1010set -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
1615package_name=$1
@@ -19,6 +18,20 @@ yalc_packages_file_name="yalc-packages"
1918container_id=" $( docker-compose ps -q web) "
2019container_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+
2235if [[ -z " ${package_name} " ]]; then
2336 if ! [[ -f " $yalc_packages_file_name " ]]; then
2437 echo " Yalc packages file doesn't exist. Creating..."
Original file line number Diff line number Diff line change @@ -10,11 +10,24 @@ set -o pipefail # don't ignore exit codes when piping output
1010set -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
1615package_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
1932echo " Unlinking package from Example Storefront..."
2033docker-compose exec web sh -c " cd /usr/local/src/app && yalc remove ${package_name} "
You can’t perform that action at this time.
0 commit comments