87 lines
1.9 KiB
Bash
Executable File
87 lines
1.9 KiB
Bash
Executable File
#! /bin/bash --
|
|
[ ! -z "${GREZZO_1577142009}" ] && return; GREZZO_1577142009=0
|
|
|
|
function feat_addpacks_npm_dev() {
|
|
if ! feat_missing "apt-get"; then
|
|
sudo apt-get install -y wget curl tar
|
|
elif ! feat_missing "pacman"; then
|
|
sudo pacman -S --needed base-devel wget curl tar
|
|
elif ! feat_missing "apk"; then
|
|
sudo apk add --no-cache wget curl tar bash
|
|
elif ! feat_missing "yum"; then
|
|
sudo yum install wget curl tar
|
|
elif ! feat_missing "zypper"; then
|
|
sudo zypper in wget curl tar
|
|
fi
|
|
}
|
|
|
|
function feat_add_npm() {
|
|
feat_addpacks_npm_dev
|
|
cat - "$HOME/.bashrc.before" <<- EOF > "$HOME/.bashrc.before.tmp"
|
|
export N_PREFIX="\$HOME/.local"
|
|
export PATH="\$N_PREFIX/bin:\$PATH"
|
|
EOF
|
|
mv "$HOME/.bashrc.before.tmp" "$HOME/.bashrc.before"
|
|
. "$HOME/.bashrc.before"
|
|
mkdir -p "$N_PREFIX"
|
|
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s latest
|
|
npm install -g n
|
|
}
|
|
|
|
function npm_initialized() {
|
|
[ -s 'package.json' ]
|
|
}
|
|
|
|
function npm_feat_added() {
|
|
npm list 2>&1 | grep -q "$FEAT@"
|
|
}
|
|
|
|
function npm-g_feat_added() {
|
|
npm list -g 2>&1 | grep -q "$FEAT@"
|
|
}
|
|
|
|
function npm_feat_missing() {
|
|
npm list 2>&1 | grep -q 'missing[^ ]* *'"$FEAT"'@'
|
|
}
|
|
|
|
function npm-g_feat_add() {
|
|
npm install -g npm
|
|
npm install -g "$1"
|
|
}
|
|
|
|
function npm_feat_add() {
|
|
npm install -g npm
|
|
npm install "$1"
|
|
}
|
|
|
|
function npm_feat_needed() {
|
|
feat_needed "npm"
|
|
FEAT="$1"
|
|
if ! npm_initialized; then
|
|
npm init -y
|
|
fi
|
|
if npm_feat_added "$FEAT"; then
|
|
if npm_feat_missing "$FEAT"; then
|
|
npm install
|
|
fi
|
|
else
|
|
if type "npm_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
|
eval "npm_feat_add_$FEAT"
|
|
else
|
|
npm_feat_add "$FEAT"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
function npm-g_feat_needed() {
|
|
feat_needed "npm"
|
|
FEAT="$1"
|
|
if ! npm-g_feat_added "$FEAT"; then
|
|
if type "npm-g_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
|
eval "npm-g_feat_add_$FEAT"
|
|
else
|
|
npm-g_feat_add "$FEAT"
|
|
fi
|
|
fi
|
|
}
|