-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathpinWorkflow.ts
More file actions
38 lines (29 loc) · 1.09 KB
/
pinWorkflow.ts
File metadata and controls
38 lines (29 loc) · 1.09 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
import * as vscode from "vscode";
import {pinWorkflow} from "../configuration/configuration";
import {GitHubRepoContext} from "../git/repository";
import {Workflow} from "../model";
import {getWorkflowUri} from "../workflow/workflow";
interface PinWorkflowCommandOptions {
gitHubRepoContext: GitHubRepoContext;
wf?: Workflow;
updateContextValue(): void;
}
export function registerPinWorkflow(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("github-actions.workflow.pin", async (args: PinWorkflowCommandOptions) => {
const {gitHubRepoContext, wf} = args;
if (!wf) {
return;
}
const workflowFullPath = getWorkflowUri(gitHubRepoContext, wf.path);
if (!workflowFullPath) {
return;
}
const relativeWorkflowPath = vscode.workspace.asRelativePath(workflowFullPath);
await pinWorkflow(relativeWorkflowPath);
args.updateContextValue();
// Refresh tree to reflect updated `pin/unpin` icon
await vscode.commands.executeCommand("github-actions.explorer.refresh");
})
);
}