Skip to content

Commit bea72c1

Browse files
committed
feat: ignore conditional imports
1 parent 20e2ab1 commit bea72c1

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

lib/travis/index.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,27 @@ internals.toArray = (v) => {
2525

2626
internals.normalizeImports = (travisYaml, { relativeTo }) => {
2727

28-
return internals.toArray(travisYaml.import).map((entry) => {
28+
return internals.toArray(travisYaml.import)
29+
.map((entry) => {
2930

30-
if (typeof entry === 'string') {
31-
entry = { source: entry };
32-
}
31+
if (typeof entry === 'string') {
32+
entry = { source: entry };
33+
}
3334

34-
if (entry.source.startsWith('./')) {
35-
entry.source = entry.source.substring(2);
35+
if (entry.source.startsWith('./')) {
36+
entry.source = entry.source.substring(2);
3637

37-
if (relativeTo) {
38-
const relativeParts = relativeTo.source.split('/');
39-
relativeParts.pop();
40-
relativeParts.push(entry.source);
41-
entry.source = relativeParts.join('/');
38+
if (relativeTo) {
39+
const relativeParts = relativeTo.source.split('/');
40+
relativeParts.pop();
41+
relativeParts.push(entry.source);
42+
entry.source = relativeParts.join('/');
43+
}
4244
}
43-
}
4445

45-
return entry;
46-
});
46+
return entry;
47+
})
48+
.filter((entry) => !entry.if); // @todo: log a warning
4749
};
4850

4951

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
import:
3+
- source: partials/indirect-node-14.yml
4+
if: branch = master

test/travis.js

+22
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,26 @@ describe('.travis.yml parsing', () => {
103103
});
104104
});
105105

106+
it('ignores conditional imports', async () => {
107+
108+
await fixture.setupRepoFolder({
109+
partials: true,
110+
travisYml: `testing-imports/conditional.yml`
111+
});
112+
113+
const result = await NodeSupport.detect({ path: fixture.path });
114+
115+
internals.assertCommit(result);
116+
117+
expect(result).to.equal({
118+
name: 'test-module',
119+
version: '0.0.0-development',
120+
timestamp: 1580673602000,
121+
travis: {
122+
raw: ['latest'],
123+
resolved: { 'latest': '13.14.0' }
124+
}
125+
});
126+
});
127+
106128
});

0 commit comments

Comments
 (0)