diff options
| author | David Barsky <me@davidbarsky.com> | 2023-03-09 15:06:26 -0500 |
|---|---|---|
| committer | David Barsky <me@davidbarsky.com> | 2023-03-13 13:30:18 -0400 |
| commit | 8af3d6367ecead0abf80e697176f697d97c25215 (patch) | |
| tree | 54a28c70aadc17ddc93991fb4344a516ae6cba29 /editors/code/src/util.ts | |
| parent | 95497533524537b1cc7a2870ce94b0b14503be8b (diff) | |
| download | rust-8af3d6367ecead0abf80e697176f697d97c25215.tar.gz rust-8af3d6367ecead0abf80e697176f697d97c25215.zip | |
This commit add Cargo-style project discovery for Buck and Bazel users.
This feature requires the user to add a command that generates a
`rust-project.json` from a set of files. Project discovery can be invoked
in two ways:
1. At extension activation time, which includes the generated
`rust-project.json` as part of the linkedProjects argument in
InitializeParams
2. Through a new command titled "Add current file to workspace", which
makes use of a new, rust-analyzer specific LSP request that adds
the workspace without erasing any existing workspaces.
I think that the command-running functionality _could_ merit being
placed into its own extension (and expose it via extension contribution
points), if only provide build-system idiomatic progress reporting and
status handling, but I haven't (yet) made an extension that does this.
Diffstat (limited to 'editors/code/src/util.ts')
| -rw-r--r-- | editors/code/src/util.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index d93b9caeb16..d2ecdce5b4e 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -150,9 +150,11 @@ export function memoizeAsync<Ret, TThis, Param extends string>( /** Awaitable wrapper around `child_process.exec` */ export function execute(command: string, options: ExecOptions): Promise<string> { + log.info(`running command: ${command}`) return new Promise((resolve, reject) => { exec(command, options, (err, stdout, stderr) => { if (err) { + log.error(err); reject(err); return; } @@ -167,6 +169,21 @@ export function execute(command: string, options: ExecOptions): Promise<string> }); } +export function executeDiscoverProject(command: string, options: ExecOptions): Promise<string> { + log.info(`running command: ${command}`) + return new Promise((resolve, reject) => { + exec(command, options, (err, stdout, _) => { + if (err) { + log.error(err); + reject(err); + return; + } + + resolve(stdout.trimEnd()); + }); + }); +} + export class LazyOutputChannel implements vscode.OutputChannel { constructor(name: string) { this.name = name; |
