Skip to content

Commit 8557d98

Browse files
authored
Merge pull request #132 from IBM/fix/windows-paths
Fix resolving of local includes on windows
2 parents 5b5a455 + bcff4da commit 8557d98

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

cli/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function globalEntryIsValid(fullPath: string, search: string, ignoreBase?
274274
}
275275

276276
const baseParts = fullPath.toUpperCase().split(path.sep);
277-
const nameParts = search.split(path.sep);
277+
const nameParts = search.split(path.posix.sep);
278278

279279
// Check the preceding parts of the path match
280280
if (nameParts.length > 1) {
@@ -297,7 +297,7 @@ export function globalEntryIsValid(fullPath: string, search: string, ignoreBase?
297297
const tempName = search.substring(0, search.length - 1);
298298
const lastChar = tempName.charAt(tempName.length - 1);
299299
const messedUpFullName = fullPath.lastIndexOf(lastChar) >= 0 ? fullPath.substring(0, fullPath.lastIndexOf(lastChar) + 1) : fullPath;
300-
if (messedUpFullName.toUpperCase().endsWith(tempName)) return true;
300+
if (messedUpFullName.replace(/\\/g, '/').toUpperCase().endsWith(tempName)) return true;
301301
} else if (!baseName.includes('.')) {
302302
// If the name does not include a dot, we check if the current part (without extension) matches
303303
let currentPart = baseParts[baseParts.length - 1];
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
import { beforeAll, describe, expect, test } from 'vitest';
2-
3-
import { Targets } from '../src/targets'
4-
import path from 'path';
5-
import { setupFixture } from './fixtures/projects';
6-
import { ReadFileSystem } from '../src/readFileSystem';
7-
8-
// This issue was occuring when you had two files with the same name, but different extensions.
9-
10-
describe(`include_mismatch_fix tests`, () => {
11-
const project = setupFixture(`include_mismatch_fix`);
12-
13-
const fs = new ReadFileSystem();
14-
const targets = new Targets(project.cwd, fs);
15-
targets.setSuggestions({renames: true, includes: true})
16-
17-
beforeAll(async () => {
18-
project.setup();
19-
await targets.loadProject();
20-
21-
expect(targets.getTargets().length).toBeGreaterThan(0);
22-
targets.resolveBinder();
23-
});
24-
25-
test(`Ensure rename is against correct file`, async () => {
26-
const articlePf = targets.getTarget({systemName: `ARTICLE`, type: `FILE`});
27-
expect(articlePf).toBeDefined();
28-
29-
const articlePfLogs = targets.logger.getLogsFor(articlePf.relativePath);
30-
expect(articlePfLogs.length).toBe(1);
31-
expect(articlePfLogs[0].message).toBe(`no object found for reference 'SAMREF'`);
32-
expect(articlePfLogs[0].type).toBe(`warning`);
33-
34-
const articleIncludeLogs = targets.logger.getLogsFor(path.join(`QPROTOSRC`, `ARTICLE.RPGLE`));
35-
expect(articleIncludeLogs.length).toBe(1);
36-
expect(articleIncludeLogs[0].message).toBe(`Rename suggestion`);
37-
expect(articleIncludeLogs[0].type).toBe(`rename`);
38-
expect(articleIncludeLogs[0].change).toMatchObject({
39-
rename: {
40-
path: path.join(project.cwd, `QPROTOSRC`, `ARTICLE.RPGLE`),
41-
newName: 'ARTICLE.rpgleinc'
42-
}
43-
})
44-
});
1+
import { beforeAll, describe, expect, test } from 'vitest';
2+
3+
import { Targets } from '../src/targets'
4+
import path from 'path';
5+
import { setupFixture } from './fixtures/projects';
6+
import { ReadFileSystem } from '../src/readFileSystem';
7+
8+
// This issue was occuring when you had two files with the same name, but different extensions.
9+
10+
describe(`include_mismatch_fix tests`, () => {
11+
const project = setupFixture(`include_mismatch_fix`);
12+
13+
const fs = new ReadFileSystem();
14+
const targets = new Targets(project.cwd, fs);
15+
targets.setSuggestions({renames: true, includes: true})
16+
17+
beforeAll(async () => {
18+
project.setup();
19+
await targets.loadProject();
20+
21+
expect(targets.getTargets().length).toBeGreaterThan(0);
22+
targets.resolveBinder();
23+
});
24+
25+
test(`Ensure rename is against correct file`, async () => {
26+
const articlePf = targets.getTarget({systemName: `ARTICLE`, type: `FILE`});
27+
expect(articlePf).toBeDefined();articlePf.relativePath
28+
29+
const articlePfLogs = targets.logger.getLogsFor(path.join(`QDDSSRC`, `ARTICLE.PF`));
30+
expect(articlePfLogs.length).toBe(1);
31+
expect(articlePfLogs[0].message).toBe(`no object found for reference 'SAMREF'`);
32+
expect(articlePfLogs[0].type).toBe(`warning`);
33+
34+
const articleIncludeLogs = targets.logger.getLogsFor(path.join(`QPROTOSRC`, `ARTICLE.RPGLE`));
35+
expect(articleIncludeLogs.length).toBe(1);
36+
expect(articleIncludeLogs[0].message).toBe(`Rename suggestion`);
37+
expect(articleIncludeLogs[0].type).toBe(`rename`);
38+
expect(articleIncludeLogs[0].change).toMatchObject({
39+
rename: {
40+
path: path.join(project.cwd, `QPROTOSRC`, `ARTICLE.RPGLE`),
41+
newName: 'ARTICLE.rpgleinc'
42+
}
43+
})
44+
});
4545
});

0 commit comments

Comments
 (0)