Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
fix(travis-api): Convert node versions return by Travis API to Strings
Browse files Browse the repository at this point in the history
Travis API return the Node version as a String or a Number based on the
way it's defined in .travis.yml (node_js: '8' => String / node_js: 8 =>
Number).
`semver` expect a String and consider invalid the versions expressed as
a Number

Fix #347
  • Loading branch information
pvdlg committed Sep 21, 2017
1 parent 18364e6 commit 4762a06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions __tests__/elect-build-leader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const electBuildLeader = require('../elect-build-leader')
test('find highest node version in build matrix', t => {
t.is(electBuildLeader('1'), 1, 'no matrix')

t.is(electBuildLeader([3, '2', 1]), 1, 'version as integers')

t.is(electBuildLeader([
'8',
'4',
Expand Down
2 changes: 2 additions & 0 deletions elect-build-leader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = versions => {
const stable = versions.indexOf('node') + 1
if (stable) return stable

// Convert to Strings as expected by semver
versions = versions.map(version => String(version))
// otherwise we use the lower bound of all valid semver ranges
const validRanges = versions.filter(semver.validRange)
const lowVersionBoundaries = validRanges
Expand Down

0 comments on commit 4762a06

Please sign in to comment.