We are using asdf-vm for node versioning. And we need to test several versions of node. I read lifecycle and nvmrc docs. but we can not hook before nvm install.
Our Project layout likes this:
<root>
|- .tool_versions
|- package.json
|- node_modules
|- ...
|- lambda
|- .tool_versions
|- package.json
|- node_modules
|- ...
Currently, We using below setting.
language: node_js
dist: trusty
sudo: false
cache:
yarn: true
before_install:
- cat .tool-versions | awk '{print $2}' > .nvmrc
- nvm install
jobs:
include:
- stage: test
script: yarn test -- --maxWorkers=4 # test for root
- script: yarn build
- before_install:
- cd lambda
- cat .tool-versions | awk '{print $2}' > .nvmrc
- nvm install
script:
- yarn test -- --maxWorkers=4 # test for lambda
# NOTE: `yarn build` is not needed for lambda
The problem of this setting is it install node twice.
...
$ nvm install 0.10 # <-- here
Node.js version v0.10.48 does not meet requirement for yarn. Please use Node.js 4 or later.
Setting up build cache
$ node --version
v0.10.48
$ npm --version
2.15.1
$ nvm --version
0.34.0
$ yarn --version
Node version 0.10.48 is not supported, please use Node.js 4.0 or higher.
before_install.1
$ cat .tool-versions | awk '{print $2}' > .nvmrc
before_install.2
$ nvm install # <-- and here
...