fix to use with sveltekit
This commit is contained in:
94
bin/node/zera
Executable file
94
bin/node/zera
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
BIN_DIR="$(cd $DIR/.. && pwd)"
|
||||
|
||||
# Import functions
|
||||
. $BIN_DIR/helper/fn
|
||||
|
||||
# Usage
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
|
||||
Usage: $0 [options...]
|
||||
|
||||
Options:
|
||||
-m, --manager <manager> Package manager: npm (default), yarn or pnpm
|
||||
-s, --shame Shamefully hoist (only pnpm)
|
||||
-h, --help Show usage
|
||||
|
||||
EOF
|
||||
exit 2
|
||||
}
|
||||
|
||||
unset CURR_FOLDER
|
||||
CURR_FOLDER="$(pwd)"
|
||||
|
||||
unset ACTION
|
||||
ACTION=npm
|
||||
|
||||
unset SHAME
|
||||
SHAME=""
|
||||
|
||||
unset VERBOSE
|
||||
VERBOSE=false
|
||||
|
||||
unset CMD_AVAILABLE
|
||||
CMD_AVAILABLE=("npm" "yarn" "pnpm")
|
||||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-m|--manager)
|
||||
ACTION="${2}"
|
||||
shift
|
||||
;;
|
||||
-s|--shame)
|
||||
SHAME="--shamefully-hoist"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
abort "Unknown option $i"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check command available
|
||||
[[ ! " ${CMD_AVAILABLE[*]} " =~ " ${ACTION} " ]] && usage
|
||||
|
||||
# Go to current directory
|
||||
cd $CURR_FOLDER
|
||||
|
||||
# Remove current data
|
||||
rm -rf \
|
||||
"${CURR_FOLDER}/node_modules" \
|
||||
"${CURR_FOLDER}/package-lock.json" \
|
||||
"${CURR_FOLDER}/yarn.lock" \
|
||||
"${CURR_FOLDER}/.yarn" \
|
||||
"${CURR_FOLDER}/.yarnrc.yml" \
|
||||
"${CURR_FOLDER}/.pnp.*" \
|
||||
"${CURR_FOLDER}/pnpm-lock.yaml"
|
||||
|
||||
# Generate .yarnrc.yml
|
||||
if [ "${ACTION}" = "yarn" ]; then
|
||||
echo "" > "${CURR_FOLDER}/.yarnrc.yml"
|
||||
yarn set version stable
|
||||
echo "nodeLinker: node-modules" >> "${CURR_FOLDER}/.yarnrc.yml"
|
||||
fi
|
||||
|
||||
# Install packages
|
||||
if [ "${ACTION}" = "pnpm" ]; then
|
||||
$ACTION install $SHAME
|
||||
else
|
||||
$ACTION install
|
||||
fi
|
||||
|
||||
# Audit packages
|
||||
test $? -ne 0 && abort "${ACTION} failed" || ok "zerado..."
|
||||
test "${ACTION}" = "yarn" && yarn npm audit || $ACTION audit
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user