-
-
Save contolini/c79fa8b193625cfeb826632299feb440 to your computer and use it in GitHub Desktop.
Removing npm tmp after install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# this is pid of the bash we are in | |
bash_pid=$$ | |
bash_pid=$(echo -e ${bash_pid} | tr -d '[[:space:]]'); | |
# this is shell of the bash | |
shell_pid=$(ps -p ${bash_pid} -o ppid=;) | |
shell_pid=$(echo -e ${shell_pid} | tr -d '[[:space:]]'); | |
# this is the npm who runs shell | |
npm_pid=$(ps -p ${shell_pid} -o ppid=;) | |
npm_pid=$(echo -e ${npm_pid} | tr -d '[[:space:]]'); | |
# test whether npm tmp configuration is set | |
# if not, assume the default /tmp | |
if [ -z ${npm_config_tmp} ]; then | |
npm_config_tmp=/tmp | |
fi; | |
echo "Removing ${npm_config_tmp}/npm-${npm_pid}*"; | |
rm -rf "${npm_config_tmp}"/npm-${npm_pid}* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
npm install -g json | |
curl -O https://gist.githubusercontent.com/contolini/c79fa8b193625cfeb826632299feb440/raw/263d9955d4d0ba77cba260b713e1918dfcab06e3/npm-tmp-clean.sh | |
chmod +x npm-tmp-clean.sh | |
json -I -f ./package.json -e 'this.scripts.postinstall="./npm-tmp-clean.sh"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment