Skip to content

Commit

Permalink
Ignore nvm aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicdoe committed Feb 2, 2017
1 parent 451de2d commit b088fe0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
12 changes: 10 additions & 2 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', 'unstable'];
const IGNORED_VERSIONS = ['node', 'lts/*', 'lts/argon', 'lts/boron'];

/**
* Normalize a semantic version to be a valid version. 0.10 -> 0.10.0
Expand Down Expand Up @@ -74,15 +75,22 @@ module.exports = ctx => {
});
}

const versions = Array.isArray(travis.node_js) ? travis.node_js : [travis.node_js];
let versions = Array.isArray(travis.node_js) ? travis.node_js : [travis.node_js];
versions = versions.filter(v => IGNORED_VERSIONS.indexOf(v) === -1);

for (const version of versions) {
if (DEPRECATED_VERSIONS.indexOf(version) !== -1) {
ctx.report({
message: `Version \`${version}\` is deprecated.`,
file
});
} else if (version !== 'node' && engine && !semver.satisfies(normalize(version), engine)) {
}
}

versions = versions.filter(v => DEPRECATED_VERSIONS.indexOf(v) === -1);

for (const version of versions) {
if (engine && !semver.satisfies(normalize(version), engine)) {
ctx.report({
message: `Unsupported version \`${version}\` is being tested.`,
fix: fixers.unsupported(version),
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/travis/aliases/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- 'node'
- 'lts/*'
- 'lts/argon'
- 'lts/boron'
- '6'
- '4'
6 changes: 6 additions & 0 deletions test/fixtures/travis/aliases/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('aliases', async t => {
await ruleTester(t, 'aliases', []);
});

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

Expand Down

0 comments on commit b088fe0

Please sign in to comment.