Skip to content

Commit

Permalink
Fix CI with older Node.js versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrv committed Apr 23, 2017
1 parent 8b2b014 commit a23b69b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ matrix:
# - os: osx
# env: CC=clang-3.8 CXX=clang++-3.8 npm_config_clang=1

before_install:
VER=`npm --version` eval 'ARRAY=(${VER//./ }) && if [ ${ARRAY[0]} -lt 2 ] || ( [ ${ARRAY[0]} -eq 2 ] && [ ${ARRAY[1]} -lt 13 ] ) ; then npm install -g npm; fi'

after_script:
if [ ${TRAVIS_JOB_NUMBER##*.} == 1 ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then bin/ci-trigger; fi

Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ matrix:
allow_failures:
- nodejs_version: 0.10
install:
- npm install -g npm
- set PATH=%APPDATA%\npm;%PATH%
- npm install
build: off
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"tslint": "tslint",
"cbuild": "cbuild",
"dump-lib": "dump-em-lib dist/em-api.js",
"lint": "tslint --type-check -c src/tslint.json -p src/tsconfig.json && tslint --type-check -c src/tslint.json -p src/em/tsconfig.json",
"prepublish": "npm run lint && tsc -p src/em && tsc -p src && cbuild -x -v -s dist/bundle/em/em-api.js -o dist/em-api.js",
"lint": "node src/checkver.js lt 4.1.2 || (tslint --type-check -c src/tslint.json -p src/tsconfig.json && tslint --type-check -c src/tslint.json -p src/em/tsconfig.json)",
"prepublish": "npm run lint && tsc -p src/em && tsc -p src && (node src/checkver.js lt 0.12.0 || cbuild -x -v -s dist/bundle/em/em-api.js -o dist/em-api.js)",
"clean-asm": "cd test/em && node-gyp clean",
"config-test": "autogypi -c test/autogypi.json",
"test-asm": "npm run config-test && cd test/em && node-gyp configure build --asmjs=1 && node ../../bin/ndts . > ../testlib.d.ts && tsc -p .. && tap ../test.js",
Expand Down
31 changes: 31 additions & 0 deletions src/checkver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

var op = process.argv[2].match(/^([gl])([te])$/);
var wanted = (process.argv[3] || '').split('.');
var version = process.versions.node.split('.');

if(!op || wanted.length != 3) {
console.log([
'usage:',
process.argv[0].replace(/.*\//, ''),
process.argv[1].replace(/.*\//, ''),
'op',
'x.y.z'
].join(' '));

console.log('\nCompare Node.js version.');
console.log('Following op codes determine whether it must be:\n');

console.log('\tgt\tGreater than x.y.z.');
console.log('\tge\tGreater than or equal to x.y.z.');
console.log('\tlt\tLess than x.y.z.');
console.log('\tle\tLess than or equal to x.y.z.');

process.exit(1);
}

for(var i = 0; i < 3; ++i) {
if(+version[i] > +wanted[i]) process.exit(+(op[1] != 'g'));
if(+version[i] < +wanted[i]) process.exit(+(op[1] == 'g'));
}

process.exit(+(op[2] != 'e'));

0 comments on commit a23b69b

Please sign in to comment.