aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/installation/download_file.ts3
-rw-r--r--editors/code/src/installation/server.ts3
-rw-r--r--editors/code/src/util.ts12
3 files changed, 10 insertions, 8 deletions
diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts
index 319cb995c..ee8949d61 100644
--- a/editors/code/src/installation/download_file.ts
+++ b/editors/code/src/installation/download_file.ts
@@ -2,8 +2,7 @@ import fetch from "node-fetch";
2import * as fs from "fs"; 2import * as fs from "fs";
3import * as stream from "stream"; 3import * as stream from "stream";
4import * as util from "util"; 4import * as util from "util";
5import { strict as assert } from "assert"; 5import { log, assert } from "../util";
6import { log } from "../util";
7 6
8const pipeline = util.promisify(stream.pipeline); 7const pipeline = util.promisify(stream.pipeline);
9 8
diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts
index cb5e56844..6a6cf4f8c 100644
--- a/editors/code/src/installation/server.ts
+++ b/editors/code/src/installation/server.ts
@@ -1,13 +1,12 @@
1import * as vscode from "vscode"; 1import * as vscode from "vscode";
2import * as path from "path"; 2import * as path from "path";
3import { strict as assert } from "assert";
4import { promises as dns } from "dns"; 3import { promises as dns } from "dns";
5import { spawnSync } from "child_process"; 4import { spawnSync } from "child_process";
6 5
7import { BinarySource } from "./interfaces"; 6import { BinarySource } from "./interfaces";
8import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; 7import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info";
9import { downloadArtifact } from "./download_artifact"; 8import { downloadArtifact } from "./download_artifact";
10import { log } from "../util"; 9import { log, assert } from "../util";
11 10
12export async function ensureServerBinary(source: null | BinarySource): Promise<null | string> { 11export async function ensureServerBinary(source: null | BinarySource): Promise<null | string> {
13 if (!source) { 12 if (!source) {
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 68c2a94d0..acf78898b 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,22 +1,26 @@
1import * as lc from "vscode-languageclient"; 1import * as lc from "vscode-languageclient";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import { strict as nodeAssert } from "assert";
3 4
4let enabled: boolean = false; 5export function assert(condition: unknown, explanation: string): asserts condition {
6 nodeAssert(condition, explanation);
7}
5 8
6export const log = { 9export const log = {
10 enabled: true,
7 debug(message?: any, ...optionalParams: any[]): void { 11 debug(message?: any, ...optionalParams: any[]): void {
8 if (!enabled) return; 12 if (!log.enabled) return;
9 // eslint-disable-next-line no-console 13 // eslint-disable-next-line no-console
10 console.log(message, ...optionalParams); 14 console.log(message, ...optionalParams);
11 }, 15 },
12 error(message?: any, ...optionalParams: any[]): void { 16 error(message?: any, ...optionalParams: any[]): void {
13 if (!enabled) return; 17 if (!log.enabled) return;
14 debugger; 18 debugger;
15 // eslint-disable-next-line no-console 19 // eslint-disable-next-line no-console
16 console.error(message, ...optionalParams); 20 console.error(message, ...optionalParams);
17 }, 21 },
18 setEnabled(yes: boolean): void { 22 setEnabled(yes: boolean): void {
19 enabled = yes; 23 log.enabled = yes;
20 } 24 }
21}; 25};
22 26