So basically when a branch is pushed I want to run a diff between the master branch and a target branch and then feed those files into eslint.
The command is:
git diff --name-only master..$TRAVIS_BRANCH | grep -E '\.js$' | xargs npx eslint
It works when I use it locally and replace $TRAVIS_BRANCH with my current working branch.
However, when I use this on travis ci, the build process only checks out the branch its testing against and not master. So it comes out with the error
$ git diff --name-only master..$TRAVIS_BRANCH | grep -E '\.js$' | xargs npx eslint
fatal: ambiguous argument 'master..test-fail': unknown revision or path not in the working tree.
How can I get travis CI to diff the files changed in a branch and run eslint only on those files?
.travis.yml
language: node_js
node_js:
- "lts/*"
- "node"
- "8"
jobs:
include:
- stage: lint
script: git diff --name-only master..$TRAVIS_BRANCH | grep -E '\.js$' | xargs npx eslint