dotfiles/.local/bin/npm

56 lines
790 B
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Trick version command
if [[ $1 == "version" ]]; then
echo "{\"npm\":\"9.8.1\"}"
exit
fi
# Trick init command
if [[ $1 == "init" ]]; then
for i in "$@"; do
case $i in
--scope=*)
SCOPE="${i#*=}"
shift # past argument=value
;;
*)
;;
esac
done
pnpm init > /dev/null
if [ -n "$SCOPE" ]; then
sed -i "s/\"name\": \"\(.*\)\"/\"name\": \"@$SCOPE\/\1\"/" package.json
fi
cat package.json
exit
fi
# Trick install command
if [[ $1 == "install" ]]; then
if [ -n "$2" ]; then
pnpm add $2
else
pnpm install
fi
exit
fi
# Trick publish command
if [[ $1 == "publish" ]]; then
corepack npm $@
exit
fi
# Trick info command
if [[ $1 == "info" ]]; then
corepack npm $@
exit
fi
pnpm $@