Coder Social home page Coder Social logo

nodenv with Travis about nodenv HOT 4 CLOSED

nodenv avatar nodenv commented on July 2, 2024
nodenv with Travis

from nodenv.

Comments (4)

jasonkarns avatar jasonkarns commented on July 2, 2024

What method of setup did you follow?

from nodenv.

skippednote avatar skippednote commented on July 2, 2024

Here is the config I'm using:
.travis.yml

sudo: false
language: php

php:
  - 5.6

env:
  global:
    - DOCROOT=$TRAVIS_BUILD_DIR/../drupal
    - NIMBUS_DIR=$DOCROOT/...redacted
    - NIMBUS_HALO_DIR=$DOCROOT/...redacted

cache:
  bundler: true
  apt: true
  directories:
  - "$HOME/.composer/cache"
  - "$HOME/.composer/vendor"
  - "$HOME/.drush/cache"
  - "$HOME/.npm"
  - "$HOME/.nodenv"
  - "$NIMBUS_HALO_DIR/node_modules"

mysql:
  database: ...redacted
  username: ...redacted
  encoding: utf8

# Set up environment.
before_install:
  # Disable xdebug.
  - phpenv config-rm xdebug.ini

  # Set up composer.
  - composer self-update
  - export PATH="$HOME/.composer/vendor/bin:$PATH"

  # Install drush
  - composer global require drush/drush:8.* --prefer-source
  - composer global require drupal/coder:8.* --prefer-source
  - phpenv rehash

  # Clear drush release history cache, to pick up new releases.
  - rm -f ~/.drush/cache/download/*---updates.drupal.org-release-history-*

  # Create MySQL Database
  - mysql -e 'create database drupal;'

  # Copy cached dependencies back to travis build dir so that they are
  # not wiped out by `drush dl drupal` command.
  - mv $NIMBUS_HALO_DIR/node_modules $TRAVIS_BUILD_DIR/

# Install Drupal and Nimbus itself.
install:
  # Install drupal default profile
  - cd ..
  - drush dl drupal --drupal-project-rename=drupal -y
  - cd drupal

  # Copy nimbus into themes/contrib/nimbus.
  - mkdir -p themes/contrib/nimbus
  - cp -R ${TRAVIS_BUILD_DIR}/* themes/contrib/nimbus/

  # Make custom dir for subtheme
  - mkdir -p themes/custom

  # Install Drupal and enable nimbus.
  - drush --verbose site-install minimal --db-url=mysql://root:@127.0.0.1/drupal --yes
  - drush en ...redacted
  - drush ...redacted

  # Set up front end dependencies.
  - cd $NIMBUS_HALO_DIR

  - ./install.sh
  - export PATH="$HOME/.nodenv/bin:$PATH"
  - eval "$(nodenv init -)"
  - npm run install-tools
  - npm rebuild node-sass

# Run nimbus tasks.
script:
  # Codesniff all files, ignore third party libraries and compiled CSS.
  - phpcs --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --ignore=*/STARTERKIT/gulp-tasks/*,*/STARTERKIT/gulpfile.js,*/STARTERKIT/theme-settings.php,*/node_modules/*,*/styleguide/*,*/css/* $NIMBUS_DIR
  - phpcs --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml --ignore=*/gulp-tasks/*,gulpfile.js,*/node_modules/*,*/styleguide/*,*/css/* $NIMBUS_HALO_DIR
  - gulp

install.sh

#!/usr/bin/env bash
COLOR_NONE='\033[0m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
COLOR_PURPLE='\033[0;35m'
SHELLTYPE="$(basename "/$SHELL")"
SHELLRC=""
NODENV_EXPORT='export PATH="$HOME/.nodenv/bin:$PATH"'
NODENV_EVAL='eval "$(nodenv init -)"'

# Update PATH
function update_path {
  echo -e "${COLOR_GREEN}Updating PATH${COLOR_NONE}"
  if [ "$SHELLTYPE" = "bash" ]; then
    if [ -f "$HOME/.bashrc" ]; then
      SHELLRC="$HOME/.bashrc"
      echo $NODENV_EXPORT >> $SHELLRC
      echo  $NODENV_EVAL >> $SHELLRC
      echo "bashrc"
    elif [ -f "$HOME/.bash_profile" ]; then
      SHELLRC="$HOME/.bash_profile"
      echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> $SHELLRC
      echo 'eval "$(nodenv init -)"' >> $SHELLRC
      echo "bp"
    fi
  elif [ "$SHELLTYPE" = "zsh" ]; then
    if [ ! grep -q $NODENV_EXPORT ~/.zshrc ] && [ ! grep -q $NODENV_EVAL ~/.zshrc ] ; then
      echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> $SHELLRC
      echo 'eval "$(nodenv init -)"' >> $SHELLRC
      echo "zsh"
    fi
  fi
}

# Install node-build
function install_nodebuild {
  echo -e "${COLOR_GREEN}Installing node-build${COLOR_NONE}"
  if [ ! -d "$HOME/.nodenv/plugins/node-build" ]; then
    source $SHELLRC
    git clone https://github.com/nodenv/node-build.git $(nodenv root)/plugins/node-build  > /dev/null 2>&1
  fi
}

# Install node local version
function install_node {
  if [ -f ".node-version" ]; then
    echo -e "${COLOR_GREEN}Installing node${COLOR_NONE}"
    nodenv install > /dev/null 2>&1
  else
    echo "${COLOR_RED}No local node version found.${COLOR_NONE}"
  fi
}

# Install nodenv
if [ ! -d "$HOME/.nodenv" ]; then
  echo -e "${COLOR_GREEN}Installing nodenv${COLOR_NONE}"
  git clone https://github.com/nodenv/nodenv.git ~/.nodenv > /dev/null 2>&1

  update_path
  install_nodebuild
  install_node

  echo -e "${COLOR_GREEN}Please restart your terminal or run the following command:${COLOR_NONE}"
  echo -e "${COLOR_PURPLE}source $SHELLRC${COLOR_NONE}"
fi

from nodenv.

jasonkarns avatar jasonkarns commented on July 2, 2024

I'm not sure how to help with this. Is nodenv cloning correctly? Is it in the correct location? Does travis allow usage of binaries in $HOME?

Can you verify that the clone is successful and the binary is where you expect it?
Can you verify that executing the binary via absolute path succeeds?
Can you verify that your $PATH is correct?
Show what which nodenv -a emits.

Though I'd take a step back and ask why you need to install nodenv on travis since they support node via nvm out of the box.

from nodenv.

jasonkarns avatar jasonkarns commented on July 2, 2024

closing as stale. feel free to re-open with further details if you still want guidance.

from nodenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.