aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-02-28 22:46:48 +0000
committerVeetaha <[email protected]>2020-02-28 22:59:42 +0000
commit6dc598fa6331de6124a255527e37804d82372fdc (patch)
treedb6d7cdc86d299685e6d206676dd08d80c61e801 /editors/code
parente7bf99e6fdddc1ec66611a0b145d796f17c46039 (diff)
vscode: simplify assert.eq() to assert() as per matklad
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/installation/download_artifact.ts7
-rw-r--r--editors/code/src/util.ts12
2 files changed, 4 insertions, 15 deletions
diff --git a/editors/code/src/installation/download_artifact.ts b/editors/code/src/installation/download_artifact.ts
index c60014c8c..97e4d67c2 100644
--- a/editors/code/src/installation/download_artifact.ts
+++ b/editors/code/src/installation/download_artifact.ts
@@ -19,11 +19,10 @@ export async function downloadArtifact(
19 installationDir: string, 19 installationDir: string,
20 displayName: string, 20 displayName: string,
21) { 21) {
22 await fs.mkdir(installationDir).catch(err => assert.eq( 22 await fs.mkdir(installationDir).catch(err => assert(
23 err?.code, 23 err?.code === "EEXIST",
24 "EEXIST",
25 `Couldn't create directory "${installationDir}" to download ` + 24 `Couldn't create directory "${installationDir}" to download ` +
26 `${artifactFileName} artifact: ${err.message}` 25 `${artifactFileName} artifact: ${err?.message}`
27 )); 26 ));
28 27
29 const installationPath = path.join(installationDir, artifactFileName); 28 const installationPath = path.join(installationDir, artifactFileName);
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 5c89bc62c..f56c6bada 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -2,7 +2,7 @@ import * as lc from "vscode-languageclient";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import { strict as nativeAssert } from "assert"; 3import { strict as nativeAssert } from "assert";
4 4
5export function assert(condition: unknown, explanation: string): asserts condition { 5export function assert(condition: boolean, explanation: string): asserts condition {
6 try { 6 try {
7 nativeAssert(condition, explanation); 7 nativeAssert(condition, explanation);
8 } catch (err) { 8 } catch (err) {
@@ -11,16 +11,6 @@ export function assert(condition: unknown, explanation: string): asserts conditi
11 } 11 }
12} 12}
13 13
14assert.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
24export const log = { 14export const log = {
25 enabled: true, 15 enabled: true,
26 debug(message?: any, ...optionalParams: any[]): void { 16 debug(message?: any, ...optionalParams: any[]): void {