Skip to content

Commit

Permalink
Skip nvm aliases when checking supported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicdoe committed Jan 26, 2017
1 parent dc90ac0 commit b0179d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const semver = require('semver');

const SUPPORTED_VERSIONS = ['0.10', '0.12', '4', '6'];
const DEPRECATED_VERSIONS = ['iojs', 'stable'];
const NVM_ALIASES = ['node', 'iojs', 'stable', 'unstable'];

/**
* Normalize a semantic version to be a valid version. 0.10 -> 0.10.0
Expand All @@ -21,6 +22,10 @@ const normalize = version => {

const isSupported = (version, engines) => {
for (const engine of engines) {
if (NVM_ALIASES.indexOf(engine) !== -1) {
continue;
}

if (semver.satisfies(normalize(engine), version)) {
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/travis/alias/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 'node'
- '6'
- '4'
6 changes: 6 additions & 0 deletions test/fixtures/travis/alias/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "travis",
"engines": {
"node": ">=4"
}
}
4 changes: 4 additions & 0 deletions test/travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ test('untested versions', async t => {
);
});

test('nvm alias', async t => {
await ruleTester(t, 'alias', []);
});

test('deprecated versions', async t => {
const file = path.resolve(opts.cwd, 'deprecated/.travis.yml');

Expand Down

0 comments on commit b0179d0

Please sign in to comment.