Skip to content

Instantly share code, notes, and snippets.

@rubyconvict
Created July 13, 2015 20:04
Show Gist options
  • Save rubyconvict/f5fa94960700e62c71ac to your computer and use it in GitHub Desktop.
Save rubyconvict/f5fa94960700e62c71ac to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/a/29490456
#!/bin/bash
# Uninstall node.js
#
# Options:
#
# -d Actually delete files, otherwise the script just _prints_ a command to delete.
# -p Installation prefix. Default /usr/local
# -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom
CMD="echo sudo rm -fr"
BOM_FILE="/var/db/receipts/org.nodejs.pkg.bom"
PREFIX="/usr/local"
while getopts "dp:f:" arg; do
case $arg in
d)
CMD="sudo rm -fr"
;;
p)
PREFIX=$arg
;;
f)
BOM_FILE=$arg
;;
esac
done
lsbom -f -l -s -pf ${BOM_FILE} \
| while read i; do
$CMD ${PREFIX}/${i}
done
$CMD ${PREFIX}/lib/node \
${PREFIX}/lib/node_modules \
${BOM_FILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment