Remove reliance on .nvmrc file and enforce node version check

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-01-30 10:38:19 +01:00
parent 305bc8e1cf
commit 50b4ef36b5
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
4 changed files with 17 additions and 32 deletions

View File

@ -46,7 +46,6 @@ local.properties
#
node_modules/
npm-debug.log
.nvmrc
# BUCK
buck-out/

1
.gitignore vendored
View File

@ -40,7 +40,6 @@ local.properties
#
node_modules/
npm-debug.log
.nvmrc
.babelrc
yarn-error.log
default.realm/

View File

@ -309,29 +309,25 @@ function install_nvm() {
}
function install_node_via_nvm() {
local nvmrc="$(repo_path)/.nvmrc"
local required_version=$(toolversion node)
cd "$(repo_path)"
if [ ! -e "$nvmrc" -o "$(nvm version v""$required_version"")" = "N/A" ]; then
if [ "$(nvm version v""$required_version"")" = "N/A" ]; then
cecho "@b@blue[[+ Installing Node $required_version]]"
nvm install $required_version
nvm alias status-im $required_version
echo status-im > "$nvmrc"
nvm use status-im
else
local version_alias=$(cat "$nvmrc")
if [ "$(nvm version status-im)" != "v$required_version" ]; then
nvm alias status-im $required_version
fi
nvm use $version_alias
nvm use status-im
local version=$(node -v)
cecho "+ Node already installed ($version_alias $version via NVM)... skipping."
cecho "+ Node already installed (status-im $version via NVM)... skipping."
fi
}

View File

@ -22,38 +22,29 @@ else
PLATFORM=$1
fi
load_nvm_if_available
if [[ $PLATFORM == 'setup' ]]; then
load_nvm_if_available
fi
if ! program_exists node || ! program_exists yarn; then
if ! program_version_exists node $EXPECTED_NODE_VERSION || ! program_version_exists yarn $EXPECTED_YARN_VERSION; then
echo -e "${YELLOW}********************************************************************************************"
nvmrc="./.nvmrc"
if [ -e "$nvmrc" ] && nvm_installed; then
version_alias=$(cat "$nvmrc")
echo -e "Please run 'nvm use $version_alias' in the terminal and try again."
else
echo -e "The current environment doesn't contain the expected versions of node and/or yarn"
echo -e " - node:\texpected\t${EXPECTED_NODE_VERSION}"
echo -e " \t\tfound\t\t$(node -v) ($(which node))"
echo -e " - yarn:\texpected\t${EXPECTED_YARN_VERSION}"
echo -e " \t\tfound\t\t$(yarn -v) ($(which yarn))"
echo -e "Please open another console to reload the environment, and then run 'make setup' if necessary."
echo -e "The current environment doesn't contain the expected versions of node and/or yarn"
echo -e " - node:\texpected\t${EXPECTED_NODE_VERSION}"
echo -e " \t\tfound\t\t$(node -v) ($(which node))"
echo -e " - yarn:\texpected\t${EXPECTED_YARN_VERSION}"
echo -e " \t\tfound\t\t$(yarn -v) ($(which yarn))"
echo -e "Please open another console to reload the environment, and then run 'make setup' if necessary."
load_nvm_if_available
if nvm_installed; then
echo -e "Afterwards, run 'nvm use status-im' in the terminal and try again."
fi
echo -e "**********************************************************************************************${NC}"
exit 1
fi
node_version=$(node -v)
if [[ $node_version != $EXPECTED_NODE_VERSION ]]; then
echo -e "${YELLOW}+ node version $node_version is installed. node version $EXPECTED_NODE_VERSION is recommended.${NC}"
fi
yarn_version=$(yarn -v)
if [[ $yarn_version != $EXPECTED_YARN_VERSION ]]; then
echo -e "${YELLOW}+ yarn version $yarn_version is installed. yarn version $EXPECTED_YARN_VERSION is recommended.${NC}"
fi
if [[ $PLATFORM == 'android' ]]; then
_localPropertiesPath=./android/local.properties
if [ ! -f $_localPropertiesPath ] || ! grep -Fq "ndk.dir" $_localPropertiesPath > /dev/null; then