Skip to content

Commit 300503e

Browse files
Remove platform arg as it's never not the process.platform
1 parent bdd2319 commit 300503e

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

extensions/ql-vscode/src/databases/local-databases/database-item-impl.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ export class DatabaseItemImpl implements DatabaseItem {
207207
return pathsEqual(
208208
databasePath,
209209
join(testdir, `${testdirbase}.testproj`),
210-
process.platform,
211210
);
212211
}
213212
} catch {

extensions/ql-vscode/src/databases/local-databases/database-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ export class DatabaseManager extends DisposableObject {
652652
private isExtensionControlledLocation(uri: vscode.Uri) {
653653
const storageUri = this.ctx.storageUri || this.ctx.globalStorageUri;
654654
if (storageUri) {
655-
return containsPath(storageUri.fsPath, uri.fsPath, process.platform);
655+
return containsPath(storageUri.fsPath, uri.fsPath);
656656
}
657657
return false;
658658
}

extensions/ql-vscode/src/pure/files.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,27 @@ export async function getDirectoryNamesInsidePath(
5151
return dirNames;
5252
}
5353

54-
function normalizePath(path: string, platform: NodeJS.Platform): string {
54+
function normalizePath(path: string): string {
5555
// On Windows, "C:/", "C:\", and "c:/" are all equivalent. We need
5656
// to normalize the paths to ensure they all get resolved to the
5757
// same format. On Windows, we also need to do the comparison
5858
// case-insensitively.
5959
path = resolve(path);
60-
if (platform === "win32") {
60+
if (process.platform === "win32") {
6161
path = path.toLowerCase();
6262
}
6363
return path;
6464
}
6565

66-
export function pathsEqual(
67-
path1: string,
68-
path2: string,
69-
platform: NodeJS.Platform,
70-
): boolean {
71-
return normalizePath(path1, platform) === normalizePath(path2, platform);
66+
export function pathsEqual(path1: string, path2: string): boolean {
67+
return normalizePath(path1) === normalizePath(path2);
7268
}
7369

7470
/**
7571
* Returns true if `parent` contains `child`, or if they are equal.
7672
*/
77-
export function containsPath(
78-
parent: string,
79-
child: string,
80-
platform: NodeJS.Platform,
81-
): boolean {
82-
return normalizePath(child, platform).startsWith(
83-
normalizePath(parent, platform),
84-
);
73+
export function containsPath(parent: string, child: string): boolean {
74+
return normalizePath(child).startsWith(normalizePath(parent));
8575
}
8676

8777
export async function readDirFullPaths(path: string): Promise<string[]> {

extensions/ql-vscode/test/matchers/toEqualPath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
1010
throw new Error("These must be of type string!");
1111
}
1212

13-
const pass = pathsEqual(actual, expectedPath, process.platform);
13+
const pass = pathsEqual(actual, expectedPath);
1414
if (pass) {
1515
return {
1616
message: () =>

extensions/ql-vscode/test/unit-tests/pure/files.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe("pathsEqual", () => {
200200
return;
201201
}
202202

203-
expect(pathsEqual(path1, path2, platform)).toEqual(expected);
203+
expect(pathsEqual(path1, path2)).toEqual(expected);
204204
},
205205
);
206206
});
@@ -295,7 +295,7 @@ describe("containsPath", () => {
295295
return;
296296
}
297297

298-
expect(containsPath(parent, child, platform)).toEqual(expected);
298+
expect(containsPath(parent, child)).toEqual(expected);
299299
},
300300
);
301301
});

0 commit comments

Comments
 (0)