How to run install only on windows when multiple OS are set?

How to run a command before_install or install only on windows?
My .travis.yml


os:
  - windows
  - linux

# test on several node versions
node_js:
  - '10'
  - 'node'

env:
- NODE_ENV=test

Something like this?

before_install:
- |-
    case $TRAVIS_OS_NAME in
      windows)
        npm i standard -g
        ;;
    esac

Yes. Imho the How do I use MSYS2? has a quite detailed example on installing and caching on Windows.

BTW: If you plan to publish to Github (releases or pages) I recommened installing MSYS2 like described, because rsync of the default env fails - see my post Gh-pages with NodeJS / Electron build

1 Like

This yes means that this is fully correct?

before_install:
- |-
    case $TRAVIS_OS_NAME in
      windows)
        npm i standard -g
        ;;
    esac

sorry, I’m not that versed in yaml combined with this case scenarios

The case-statement is the usual Bash syntax, and we’re using the documented environment variable. The YAML |- multiline string operator is a combination of:

  • literal style (newlines are retained in the value)
  • strip chomping (final newline is removed)
1 Like