Skip to content

Commit

Permalink
chore: use script to handle the commitlint logic
Browse files Browse the repository at this point in the history
This script was already used on Dredd Transactions, but I forgot it's there. Porting it to Dredd as well as it's smart and convenient.
  • Loading branch information
honzajavorek committed Dec 4, 2018
1 parent 018effa commit af15982
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -8,9 +8,6 @@ cache:
directories:
- "node_modules"
before_install:
# Travis CI has only shallow clone of the repository. We need to get the 'master' branch
# so 'commitlint' could compare commits and lint them: marionebl/conventional-changelog-lint#7
- "git remote set-branches origin master && git fetch && git checkout master && git checkout -"
- "npm -g install npm@6"
- "pyenv global 3.6"
- "pip install pip --upgrade"
Expand Down
6 changes: 2 additions & 4 deletions package.json
Expand Up @@ -17,15 +17,13 @@
"docs:test-extensions": "python -m unittest docs/_extensions/*.py --verbose",
"docs:build": "sphinx-build -nW -b html ./docs ./docs/_build",
"docs:serve": "sphinx-autobuild ./docs ./docs/_build",
"lint:commits": "commitlint --from=master",
"lint:code": "eslint .",
"lint": "npm run lint:commits && npm run lint:code",
"lint": "./scripts/commitlint.sh && eslint .",
"prepare": "npm run build",
"pretest": "npm run build",
"test": "mocha \"./test/**/*-test.js\"",
"test:coverage": "./scripts/coverage.sh",
"test:debug": "mocha --debug-brk \"./test/**/*-test.js\"",
"ci:lint": "commitlint-travis && npm run lint:code && npm run docs:lint && npm run docs:test-extensions",
"ci:lint": "npm run lint && npm run docs:lint && npm run docs:test-extensions",
"ci:docs": "npm run docs:build",
"ci:test": "npm run test:coverage && npm run coveralls",
"ci:release": "semantic-release && npm dist-tag add \"dredd@$(npm view dredd version)\" stable"
Expand Down
16 changes: 16 additions & 0 deletions scripts/commitlint.sh
@@ -0,0 +1,16 @@
#!/bin/bash
# Validates format of the commit messages on Travis CI


set -e # aborts as soon as anything returns non-zero exit status


if [ ! -z "$TRAVIS" ]; then
git remote set-branches origin master
git fetch --unshallow --quiet
git checkout master --quiet
git checkout - --quiet
./node_modules/.bin/commitlint-travis
else
./node_modules/.bin/commitlint --from=master
fi

0 comments on commit af15982

Please sign in to comment.