Last active
February 4, 2018 01:15
-
-
Save nemisj/11f6d01ef9638af283d3 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
{ | |
"scripts": { | |
"postinstall": "./bin/npm-tmp-clean.sh" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment