Skip to content

Commit

Permalink
fix(build): fix script to fix sem-ver
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Mar 15, 2018
1 parent 2af1c61 commit ac8f104
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
cache:
directories:
- ~/.npm
- node_modules
notifications:
email: false
node_js:
Expand All @@ -14,19 +15,19 @@ branches:
- /^greenkeeper.*$/

before_install:
- ./scripts/run-on-node-version.sh "npm install -g greenkeeper-lockfile@1"
- ./scripts/run-on-node-version.sh 9 "npm install -g greenkeeper-lockfile@1"

before_script:
- ./scripts/run-on-node-version.sh "greenkeeper-lockfile-update"
- ./scripts/run-on-node-version.sh 9 "greenkeeper-lockfile-update"

script:
- npm run verify

after_success:
- npm install -g travis-deploy-once@4
- travis-deploy-once "npm run semantic-release"
- ./scripts/run-on-node-version.sh "npm install --no-save coveralls && npm run coveralls"
- ./scripts/run-on-node-version.sh "npm install --no-save codecov && npm run codecov"
- ./scripts/run-on-node-version.sh 9 "npm install --no-save coveralls && npm run coveralls"
- ./scripts/run-on-node-version.sh 9 "npm install --no-save codecov && npm run codecov"

after_script:
- ./scripts/run-on-node-version.sh "greenkeeper-lockfile-upload"
- ./scripts/run-on-node-version.sh 9 "greenkeeper-lockfile-upload"
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"clean": "rimraf dist-es5 dist-es2015",
"dc": "npm run dependency-check",
"dependency-check": "dependency-check . --unused --no-dev -i flux-standard-action -i @types/fbemitter && dependency-check . --missing --no-dev",
"lint": "tslint -p tsconfig.json \"src/**/*.ts\"",
"prepare": "npm run build",
"postpublish": "git push",
"preversion": "git pull && npm run verify",
"lint": "tslint -p tsconfig.json 'src/**/*.ts'",
"prepublishOnly": "npm run build",
"verify": "npm run lint && npm run coverage && npm run dependency-check",
"coverage": "nyc npm test",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
Expand Down
23 changes: 19 additions & 4 deletions scripts/run-on-node-version.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#! /bin/bash
latest_version=$(npm info node version);

# Thanks to Night Train:
# https://stackoverflow.com/questions/48250235/how-to-setup-travis-to-skip-script-on-particular-nodejs-version
# https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
#
# To use this, create this file (e.g. under scripts folder: ./scripts/run-on-node-version.sh)
# and give it execution permission: chmod ugo+x scripts/run-on-node-version.sh
# Then you can use it in CI configurations, e.g. .travis.yml:
# - ./scripts/run-on-node-version.sh latest "npm install --no-save coveralls && npm run coveralls"

if [ $1 = 'latest' ]; then
target_version=$(npm info node version);
else
target_version=$1;
fi
node_version=$(node -v);
if [ ${node_version:1:1} = ${latest_version:0:1} ]; then
eval $1;
if [ ${node_version:1:1} = ${target_version:0:1} ]; then
echo "Detected ${node_version}, satisfying ${target_version}. Executing command";
eval $2;
else
echo "NodeJS ${node_version} instead of latest (${latest_version:0:1}) is detected. Skipping command";
echo "NodeJS ${node_version} instead of latest (${target_version:0:1}) is detected. Skipping command";
fi

0 comments on commit ac8f104

Please sign in to comment.