Can I hook before nvm install?

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
...

I would love travis support for asdf and/or .tool-versions, but this would only be sensible when only one version per runtime is being tested. Often projects want to check their software on multiple versions.

The one part of the lifecycle which could be hacked to support this is the apt addons, which can be any ppa: , so it should be possible to install an pure asdf-vm package (doesnt exist yet: https://repology.org/project/asdf-vm/versions) and plugins, and also install an extra package which fiddles with the language switcher to use asdf instead. This approach would scale well across lots of languages, and would be especially helpful for JVM selection. Customisation of the PATH in the travis job spec also happens before nvm install, so the apt package nvm wrapper could be selected dynamically by the job spec by adjusting the PATH to include the wrapper explicitly, thereby not breaking the default nvm on the jobs.

Imprint