-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathopenWorkflowFile.ts
More file actions
35 lines (30 loc) · 1.07 KB
/
openWorkflowFile.ts
File metadata and controls
35 lines (30 loc) · 1.07 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
import * as vscode from "vscode";
import {GitHubRepoContext} from "../git/repository";
import {Workflow} from "../model";
import {getWorkflowUri} from "../workflow/workflow";
interface OpenWorkflowCommandArgs {
gitHubRepoContext: GitHubRepoContext;
wf: Workflow;
}
export function registerOpenWorkflowFile(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand(
"github-actions.explorer.openWorkflowFile",
async (args: OpenWorkflowCommandArgs) => {
const {wf, gitHubRepoContext} = args;
const fileUri = getWorkflowUri(gitHubRepoContext, wf.path);
if (fileUri) {
try {
const textDocument = await vscode.workspace.openTextDocument(fileUri);
await vscode.window.showTextDocument(textDocument);
return;
} catch (e) {
// Ignore error and show error message below
}
}
// File not found in workspace
await vscode.window.showErrorMessage(`Workflow ${wf.path} not found in current workspace`);
}
)
);
}