-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathbuf-config-ls-modules.ts
More file actions
39 lines (37 loc) · 1.21 KB
/
buf-config-ls-modules.ts
File metadata and controls
39 lines (37 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as vscode from "vscode";
import { log } from "../log";
import { bufState } from "../state";
import { Command } from "./command";
/**
* Minimum Buf version required for `buf config ls-modules` command.
*/
const minBufVersion = "v1.34.0";
/**
* bufConfigLsModules shows the output channel and runs `buf config ls-modules` at the root
* of each VS Code workspace folder. If there are no workspace folders, then bufConfigLsModules
* displays a warning and is a no-op.
*/
export const bufConfigLsModules = new Command(
"buf.configlsmodules",
"COMMAND_TYPE_BUF",
async () => {
log.show();
if (!vscode.workspace.workspaceFolders) {
log.warn(`No workspace found, unable to run "buf config ls-modules"`);
return;
}
const bufVersion = bufState.getBufBinaryVersion();
if (bufVersion?.compare(minBufVersion) === -1) {
log.warn(
`Current Buf Version ${bufVersion} does not meet minimum required version ${minBufVersion}, unable to run "buf config ls-modules".`
);
return;
}
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
bufState.execBufCommand(
["config", "ls-modules"],
workspaceFolder.uri.path
);
}
}
);