diff options
| author | vsrs <vit@conrlab.com> | 2021-04-22 16:09:46 +0300 |
|---|---|---|
| committer | vsrs <vit@conrlab.com> | 2021-04-22 16:09:46 +0300 |
| commit | 1ebfe11730191e914dcf20297cdfdac5b7c297fc (patch) | |
| tree | ae6caf9e8fd50e3eac826d0a3f0698c6e047544f /editors/code/src/util.ts | |
| parent | 8f781e782c7e16aa323672620753ec31526d2b90 (diff) | |
| download | rust-1ebfe11730191e914dcf20297cdfdac5b7c297fc.tar.gz rust-1ebfe11730191e914dcf20297cdfdac5b7c297fc.zip | |
Add special `auto` value for `debug.sourceFileMap`
Diffstat (limited to 'editors/code/src/util.ts')
| -rw-r--r-- | editors/code/src/util.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 53492a445c4..fc5c9e94e5e 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<Ret, TThis, Param extends string>(func: (this: TThis, ar return result; }; } + +/** Awaitable wrapper around `child_process.exec` */ +export function execute(command: string, options: ExecOptions): Promise<string> { + 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 |
