From 1ebfe11730191e914dcf20297cdfdac5b7c297fc Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 22 Apr 2021 16:09:46 +0300 Subject: Add special `auto` value for `debug.sourceFileMap` --- editors/code/src/util.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'editors/code/src/util.ts') 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 @@ import * as lc from "vscode-languageclient/node"; import * as vscode from "vscode"; import { strict as nativeAssert } from "assert"; -import { spawnSync } from "child_process"; +import { exec, ExecOptions, spawnSync } from "child_process"; import { inspect } from "util"; export function assert(condition: boolean, explanation: string): asserts condition { @@ -141,3 +141,22 @@ export function memoize(func: (this: TThis, ar return result; }; } + +/** Awaitable wrapper around `child_process.exec` */ +export function execute(command: string, options: ExecOptions): Promise { + return new Promise((resolve, reject) => { + exec(command, options, (err, stdout, stderr) => { + if (err) { + reject(err); + return; + } + + if (stderr) { + reject(new Error(stderr)); + return; + } + + resolve(stdout.trimEnd()); + }); + }); +} \ No newline at end of file -- cgit v1.2.3