if [ -d "${HOME}/.nvm/" ]
then
  . ${HOME}/.nvm/nvm.sh
fi


checkNode(){
  for line in `node -v` 
  do
  if [ $line != "v10.15.0" ]
  then
    nvm use v10.15.0
    ret=$?
    if [ $ret != 0 ]
    then
      echo -e "\033[41;37m Change Node to v10.15.0 (try nvm use v10.15.0)\033[0m"
      return 0
    else
      return 1
    fi
  else
    return 1
  fi
  done
}


run(){
  npm i
  node_modules/.bin/gulp iconfont
  echo '生成完毕，请前往 dist 查看结果'
}

checkNode
ret=$?
if [ $ret = 1 ]
then
  run
fi
