Skip to content

Commit 3ad0574

Browse files
author
Veetaha
committed
vscode: add equality assertion
1 parent 9cf2577 commit 3ad0574

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

editors/code/src/installation/download_artifact.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as vscode from "vscode";
22
import * as path from "path";
33
import { promises as fs } from "fs";
4-
import { strict as assert } from "assert";
54

65
import { ArtifactReleaseInfo } from "./interfaces";
76
import { downloadFile } from "./download_file";
7+
import { assert } from "../util";
88

99
/**
1010
* Downloads artifact from given `downloadUrl`.
@@ -19,7 +19,7 @@ export async function downloadArtifact(
1919
installationDir: string,
2020
displayName: string,
2121
) {
22-
await fs.mkdir(installationDir).catch(err => assert.strictEqual(
22+
await fs.mkdir(installationDir).catch(err => assert.eq(
2323
err?.code,
2424
"EEXIST",
2525
`Couldn't create directory "${installationDir}" to download ` +

editors/code/src/util.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ 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+
1424
export const log = {
1525
enabled: true,
1626
debug(message?: any, ...optionalParams: any[]): void {

0 commit comments

Comments
 (0)