Last active
August 29, 2015 14:24
-
-
Save evanshortiss/1f1277bb6a7d4c01ea96 to your computer and use it in GitHub Desktop.
Alias that runs a function to determine which version of Cordova to use for your environment.
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
# Use a local version of Cordova when possible | |
alias cordova=exec_cordova_local | |
# Determine cordova version to use | |
exec_cordova_local() { | |
# Default path Cordova should be at if installed... | |
cpath="/usr/local/lib/node_modules/cordova/bin/cordova" | |
if [ -e node_modules/.bin/cordova ] | |
then | |
# Use a locally installed version if possible | |
cpath="node_modules/.bin/cordova" | |
elif [ -e ~/.nvm ] | |
then | |
# No local version, but user has nvm installed, | |
# so use whichever version is installed for current node runtime | |
nver=`nvm ls | grep "current:" | cut -c 11-18` | |
cpath="~/.nvm/${nver}/lib/node_modules/cordova/bin/cordova" | |
fi | |
echo "Using Cordova version located at ${cpath}" | |
cpath+=' "$@"' | |
eval $cpath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment