slap/install.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2014-12-31 23:12:55 +03:00
#!/bin/sh
set -e
is_executable () {
command -v "$1" >/dev/null 2>&1
}
alias errcho='>&2 echo'
2014-12-31 23:25:25 +03:00
npm_needs_sudo=''
2014-12-31 23:12:55 +03:00
echo "# Installing slap..."
if ! (is_executable npm && is_executable node); then
if is_executable brew; then
brew install node
2014-12-31 23:25:25 +03:00
npm_needs_sudo='false'
2014-12-31 23:12:55 +03:00
elif is_executable port; then
port install nodejs
elif is_executable apt-get; then
wget -qO- https://deb.nodesource.com/setup | sudo bash - # Adds NodeSource repository to dpkg
sudo apt-get install -y nodejs
elif is_executable yum; then
curl -sL https://rpm.nodesource.com/setup | bash - # Adds NodeSource repository to yum
sudo yum install -y nodejs
elif is_executable emerge; then
emerge nodejs
elif is_executable pacman; then
pacman -S nodejs
else
errcho "Couldn't determine OS. Please install NodeJS manually, then run this script again."
errcho "Visit https://github.com/joyent/node/wiki/installing-node.js-via-package-manager for instructions on how to install NodeJS on your OS."
exit 1
fi
fi
2014-12-31 23:25:25 +03:00
if [ -z $npm_needs_sudo ]; then
2014-12-31 23:12:55 +03:00
sudo npm install -g slap
else
npm install -g slap
fi