From b6a12f35a8d4ec7f2b40379a3f105a6838756054 Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola Date: Mon, 25 Nov 2024 00:10:45 -0500 Subject: [PATCH] Add getActCommand Signed-off-by: Sanjula Ganepola --- package.json | 2 +- src/act.ts | 12 ++++++++---- src/componentsManager.ts | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6029881..43a7578 100644 --- a/package.json +++ b/package.json @@ -686,7 +686,7 @@ "title": "GitHub Local Actions", "properties": { "githubLocalActions.actCommand": { - "markdownDescription": "The base `nektos/act` command to be called. By default, this will be `act` (requires the binary to be on your `PATH`). If the binary is not on your `PATH`, the command can be fully qualified. If `act` is installed as a GitHub CLI extension, this command should be set to `gh act`.", + "markdownDescription": "The base `nektos/act` command to be called. By default, this will be `act` (requires the binary to be on your `PATH`). If the binary is not on your `PATH`, the command should be fully qualified. If `act` is installed as a GitHub CLI extension, this command should be set to `gh act`.", "type": "string", "default": "act" }, diff --git a/src/act.ts b/src/act.ts index 9df35fe..0959854 100644 --- a/src/act.ts +++ b/src/act.ts @@ -68,7 +68,7 @@ export interface CommandArgs { export class Act { static command: string = 'act'; - static githubCliCommand: string = 'act'; + static githubCliCommand: string = 'gh act'; context: ExtensionContext; storageManager: StorageManager; secretManager: SecretManager; @@ -216,6 +216,10 @@ export class Act { }); } + static getActCommand() { + return ConfigurationManager.get(Section.actCommand) || Act.command; + } + async runAllWorkflows(workspaceFolder: WorkspaceFolder) { return await this.runCommand({ path: workspaceFolder.uri.fsPath, @@ -307,7 +311,7 @@ export class Act { } catch (error: any) { } // Build command with settings - const actCommand = ConfigurationManager.get(Section.actCommand) || Act.command; + const actCommand = Act.getActCommand(); const settings = await this.settingsManager.getSettings(workspaceFolder, true); const command = `set -o pipefail; ` + @@ -391,9 +395,9 @@ export class Act { }); if (command.includes('gh-act')) { - ConfigurationManager.set(Section.actCommand, Act.command); - } else { ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); + } else { + ConfigurationManager.set(Section.actCommand, Act.command); } } } diff --git a/src/componentsManager.ts b/src/componentsManager.ts index d3400e2..acdaaeb 100644 --- a/src/componentsManager.ts +++ b/src/componentsManager.ts @@ -1,5 +1,6 @@ import * as childProcess from "child_process"; import { commands, env, extensions, QuickPickItemKind, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, ThemeIcon, Uri, window } from "vscode"; +import { Act } from "./act"; import { ConfigurationManager, Platform, Section } from "./configurationManager"; import { act, componentsTreeDataProvider } from "./extension"; import ComponentsTreeDataProvider from "./views/components/componentsTreeDataProvider"; @@ -33,7 +34,7 @@ export class ComponentsManager { async getComponents(): Promise[]> { const components: Component[] = []; - const actCliInfo = await this.getCliInfo('act --version', /act version (.+)/, false, false); + const actCliInfo = await this.getCliInfo(`${Act.getActCommand()} --version`, /act version (.+)/, false, false); components.push({ name: 'nektos/act', icon: 'terminal',