Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # this is pid of the bash we are in
  4. bash_pid=$$
  5. bash_pid=$(echo -e ${bash_pid} | tr -d '[[:space:]]');
  6.  
  7. # this is shell of the bash
  8. shell_pid=$(ps -p ${bash_pid} -o ppid=;)
  9. shell_pid=$(echo -e ${shell_pid} | tr -d '[[:space:]]');
  10.  
  11. # this is the npm who runs shell
  12. npm_pid=$(ps -p ${shell_pid} -o ppid=;)
  13. npm_pid=$(echo -e ${npm_pid} | tr -d '[[:space:]]');
  14.  
  15. # test whether npm tmp configuration is set
  16. # if not, assume the default /tmp
  17. if [ -z ${npm_config_tmp} ]; then
  18. npm_config_tmp=/tmp
  19. fi;
  20.  
  21. echo "Removing ${npm_config_tmp}/npm-${npm_pid}*";
  22. rm -rf "${npm_config_tmp}"/npm-${npm_pid}*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement