aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/util.ts
diff options
context:
space:
mode:
authorvsrs <[email protected]>2021-04-22 14:09:46 +0100
committervsrs <[email protected]>2021-04-22 14:09:46 +0100
commit1ebfe11730191e914dcf20297cdfdac5b7c297fc (patch)
treeae6caf9e8fd50e3eac826d0a3f0698c6e047544f /editors/code/src/util.ts
parent8f781e782c7e16aa323672620753ec31526d2b90 (diff)
Add special `auto` value for `debug.sourceFileMap`
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r--editors/code/src/util.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 53492a445..fc5c9e94e 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,7 +1,7 @@
1import * as lc from "vscode-languageclient/node"; 1import * as lc from "vscode-languageclient/node";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import { strict as nativeAssert } from "assert"; 3import { strict as nativeAssert } from "assert";
4import { spawnSync } from "child_process"; 4import { exec, ExecOptions, spawnSync } from "child_process";
5import { inspect } from "util"; 5import { inspect } from "util";
6 6
7export function assert(condition: boolean, explanation: string): asserts condition { 7export function assert(condition: boolean, explanation: string): asserts condition {
@@ -141,3 +141,22 @@ export function memoize<Ret, TThis, Param extends string>(func: (this: TThis, ar
141 return result; 141 return result;
142 }; 142 };
143} 143}
144
145/** Awaitable wrapper around `child_process.exec` */
146export function execute(command: string, options: ExecOptions): Promise<string> {
147 return new Promise((resolve, reject) => {
148 exec(command, options, (err, stdout, stderr) => {
149 if (err) {
150 reject(err);
151 return;
152 }
153
154 if (stderr) {
155 reject(new Error(stderr));
156 return;
157 }
158
159 resolve(stdout.trimEnd());
160 });
161 });
162} \ No newline at end of file