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

Commit 4762a06

Browse files
committed
fix(travis-api): Convert node versions return by Travis API to Strings
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
1 parent 18364e6 commit 4762a06

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

__tests__/elect-build-leader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const electBuildLeader = require('../elect-build-leader')
55
test('find highest node version in build matrix', t => {
66
t.is(electBuildLeader('1'), 1, 'no matrix')
77

8+
t.is(electBuildLeader([3, '2', 1]), 1, 'version as integers')
9+
810
t.is(electBuildLeader([
911
'8',
1012
'4',

elect-build-leader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = versions => {
99
const stable = versions.indexOf('node') + 1
1010
if (stable) return stable
1111

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

0 commit comments

Comments
 (0)