Skip to content

Commit 7c5baeb

Browse files
committed
feat: handle .travis.yml with duplicate keys
1 parent 9fa98f0 commit 7c5baeb

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

lib/travis.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ exports.detect = async ({ loadFile }) => {
9090
throw err;
9191
}
9292

93-
const travisYaml = Yaml.safeLoad(buffer, { schema: Yaml.FAILSAFE_SCHEMA });
93+
const travisYaml = Yaml.safeLoad(buffer, {
94+
schema: Yaml.FAILSAFE_SCHEMA,
95+
json: true
96+
});
9497

9598
return {
9699
travis: await internals.scan(travisYaml)

test/fixtures/npm-promzard.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
language: node_js
3+
node_js:
4+
- '0.8'
5+
- '0.10'
6+
- '0.12'
7+
- 'iojs'
8+
before_install:
9+
- npm install -g npm@latest

test/index.js

+26
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,32 @@ describe('detect-node-support', () => {
453453
});
454454
});
455455

456+
it('handles duplicate key in .travis.yml', async () => {
457+
458+
const path = await internals.prepareFixture({
459+
travisYml: 'npm-promzard.yml'
460+
});
461+
462+
const result = await NodeSupport.detect({ path });
463+
464+
internals.assertCommit(result);
465+
466+
expect(result).to.equal({
467+
name: 'test-module',
468+
version: '0.0.0-development',
469+
timestamp: 1580673602000,
470+
travis: {
471+
raw: ['0.8', '0.10', '0.12', 'iojs'],
472+
resolved: {
473+
'0.8': '0.8.28',
474+
'0.10': '0.10.48',
475+
'0.12': '0.12.18',
476+
'iojs': false
477+
}
478+
}
479+
});
480+
});
481+
456482
it('throws when path is not a git repo', async () => {
457483

458484
const path = await internals.prepareFixture({ git: false });

0 commit comments

Comments
 (0)