Skip to content

Commit 6dc598f

Browse files
author
Veetaha
committed
vscode: simplify assert.eq() to assert() as per matklad
1 parent e7bf99e commit 6dc598f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

editors/code/src/installation/download_artifact.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ export async function downloadArtifact(
1919
installationDir: string,
2020
displayName: string,
2121
) {
22-
await fs.mkdir(installationDir).catch(err => assert.eq(
23-
err?.code,
24-
"EEXIST",
22+
await fs.mkdir(installationDir).catch(err => assert(
23+
err?.code === "EEXIST",
2524
`Couldn't create directory "${installationDir}" to download ` +
26-
`${artifactFileName} artifact: ${err.message}`
25+
`${artifactFileName} artifact: ${err?.message}`
2726
));
2827

2928
const installationPath = path.join(installationDir, artifactFileName);

editors/code/src/util.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as lc from "vscode-languageclient";
22
import * as vscode from "vscode";
33
import { strict as nativeAssert } from "assert";
44

5-
export function assert(condition: unknown, explanation: string): asserts condition {
5+
export function assert(condition: boolean, explanation: string): asserts condition {
66
try {
77
nativeAssert(condition, explanation);
88
} catch (err) {
@@ -11,16 +11,6 @@ export function assert(condition: unknown, explanation: string): asserts conditi
1111
}
1212
}
1313

14-
assert.eq = <T>(bibba: unknown, bobba: T, explanation: string): asserts bibba is T => {
15-
try {
16-
nativeAssert.strictEqual(bibba, bobba, explanation);
17-
} catch (err) {
18-
log.error(`Equality assertion failed:`, explanation);
19-
throw err;
20-
}
21-
};
22-
23-
2414
export const log = {
2515
enabled: true,
2616
debug(message?: any, ...optionalParams: any[]): void {

0 commit comments

Comments
 (0)