Skip to content

Commit cce396c

Browse files
committed
feat: resolve indirect relative import at root with a ./
1 parent dd032e8 commit cce396c

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

lib/travis/index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ internals.normalizeImports = (travisYaml, { relativeTo }) => {
3232
}
3333

3434
if (entry.source.startsWith('./')) {
35-
const relativeParts = relativeTo.source.split('/');
36-
relativeParts.pop();
37-
relativeParts.push(entry.source.substring(2));
38-
entry.source = relativeParts.join('/');
35+
entry.source = entry.source.substring(2);
36+
37+
if (relativeTo) {
38+
const relativeParts = relativeTo.source.split('/');
39+
relativeParts.pop();
40+
relativeParts.push(entry.source);
41+
entry.source = relativeParts.join('/');
42+
}
3943
}
4044

4145
return entry;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
import:
3+
- source: ./partials/indirect-node-14.yml

test/travis.js

+22
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,26 @@ describe('.travis.yml parsing', () => {
8181
});
8282
});
8383

84+
it('resolves indirect imports (./)', async () => {
85+
86+
await fixture.setupRepoFolder({
87+
partials: true,
88+
travisYml: `testing-imports/indirect-dot-slash.yml`
89+
});
90+
91+
const result = await NodeSupport.detect({ path: fixture.path });
92+
93+
internals.assertCommit(result);
94+
95+
expect(result).to.equal({
96+
name: 'test-module',
97+
version: '0.0.0-development',
98+
timestamp: 1580673602000,
99+
travis: {
100+
raw: ['14'],
101+
resolved: { '14': '14.3.0' }
102+
}
103+
});
104+
});
105+
84106
});

0 commit comments

Comments
 (0)