Last active
January 30, 2024 09:47
-
-
Save x86demon/c768f1890cb90a52325e707f78ddfb0b to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
SCRIPT=`basename "$0"` | |
MASTER_NPM_PATH="/opt/node/v20/bin" | |
NPM_PATH_51="/opt/node/v18/bin" | |
NPM_PATH_50="/opt/node/v16/bin" | |
OLD_NPM_PATH="/opt/node/v14/bin" | |
SCRIPT_BIN="${OLD_NPM_PATH}/${SCRIPT}" | |
if [[ -f .nvmrc ]] | |
then | |
NODE_VERSION=$(<.nvmrc) | |
SCRIPT_BIN="/opt/node/v${NODE_VERSION}/bin/${SCRIPT}" | |
else | |
CURRENT_GIT_BRANCH=$(git branch --remote --verbose --no-abbrev --contains | sed -rne 's/^[^\/]*\/([^\ ]+).*$/\1/p' 2> /dev/null) | |
if [[ $CURRENT_GIT_BRANCH == "" ]] | |
then | |
CURRENT_GIT_BRANCH=$(git branch --show-current 2> /dev/null) | |
fi | |
if [[ $CURRENT_GIT_BRANCH =~ "master" || !($CURRENT_GIT_BRANCH =~ "5.1" || $CURRENT_GIT_BRANCH =~ "_51" || $CURRENT_GIT_BRANCH =~ "5.0" || $CURRENT_GIT_BRANCH =~ "_50" || $CURRENT_GIT_BRANCH =~ "4.2" || $CURRENT_GIT_BRANCH =~ "_42" || $CURRENT_GIT_BRANCH =~ "4.1" || $CURRENT_GIT_BRANCH =~ "_41" || $CURRENT_GIT_BRANCH =~ "3.1" || $CURRENT_GIT_BRANCH =~ "_31" || $CURRENT_GIT_BRANCH =~ "2.6")]] | |
then | |
SCRIPT_BIN="${MASTER_NPM_PATH}/${SCRIPT}" | |
fi | |
if [[ $CURRENT_GIT_BRANCH =~ "5.1" || $CURRENT_GIT_BRANCH =~ "_51" ]] | |
then | |
SCRIPT_BIN="${NPM_PATH_51}/${SCRIPT}" | |
fi | |
if [[ $CURRENT_GIT_BRANCH =~ "5.0" || $CURRENT_GIT_BRANCH =~ "_50" ]] | |
then | |
SCRIPT_BIN="${NPM_PATH_50}/${SCRIPT}" | |
fi | |
fi | |
${SCRIPT_BIN} $@ |
Author
x86demon
commented
Jan 28, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment