Add getActCommand

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-11-25 00:10:45 -05:00
parent b0e07549a6
commit b6a12f35a8
3 changed files with 11 additions and 6 deletions

View File

@@ -686,7 +686,7 @@
"title": "GitHub Local Actions", "title": "GitHub Local Actions",
"properties": { "properties": {
"githubLocalActions.actCommand": { "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", "type": "string",
"default": "act" "default": "act"
}, },

View File

@@ -68,7 +68,7 @@ export interface CommandArgs {
export class Act { export class Act {
static command: string = 'act'; static command: string = 'act';
static githubCliCommand: string = 'act'; static githubCliCommand: string = 'gh act';
context: ExtensionContext; context: ExtensionContext;
storageManager: StorageManager; storageManager: StorageManager;
secretManager: SecretManager; secretManager: SecretManager;
@@ -216,6 +216,10 @@ export class Act {
}); });
} }
static getActCommand() {
return ConfigurationManager.get<string>(Section.actCommand) || Act.command;
}
async runAllWorkflows(workspaceFolder: WorkspaceFolder) { async runAllWorkflows(workspaceFolder: WorkspaceFolder) {
return await this.runCommand({ return await this.runCommand({
path: workspaceFolder.uri.fsPath, path: workspaceFolder.uri.fsPath,
@@ -307,7 +311,7 @@ export class Act {
} catch (error: any) { } } catch (error: any) { }
// Build command with settings // Build command with settings
const actCommand = ConfigurationManager.get<string>(Section.actCommand) || Act.command; const actCommand = Act.getActCommand();
const settings = await this.settingsManager.getSettings(workspaceFolder, true); const settings = await this.settingsManager.getSettings(workspaceFolder, true);
const command = const command =
`set -o pipefail; ` + `set -o pipefail; ` +
@@ -391,9 +395,9 @@ export class Act {
}); });
if (command.includes('gh-act')) { if (command.includes('gh-act')) {
ConfigurationManager.set(Section.actCommand, Act.command);
} else {
ConfigurationManager.set(Section.actCommand, Act.githubCliCommand); ConfigurationManager.set(Section.actCommand, Act.githubCliCommand);
} else {
ConfigurationManager.set(Section.actCommand, Act.command);
} }
} }
} }

View File

@@ -1,5 +1,6 @@
import * as childProcess from "child_process"; import * as childProcess from "child_process";
import { commands, env, extensions, QuickPickItemKind, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, ThemeIcon, Uri, window } from "vscode"; 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 { ConfigurationManager, Platform, Section } from "./configurationManager";
import { act, componentsTreeDataProvider } from "./extension"; import { act, componentsTreeDataProvider } from "./extension";
import ComponentsTreeDataProvider from "./views/components/componentsTreeDataProvider"; import ComponentsTreeDataProvider from "./views/components/componentsTreeDataProvider";
@@ -33,7 +34,7 @@ export class ComponentsManager {
async getComponents(): Promise<Component<CliStatus | ExtensionStatus>[]> { async getComponents(): Promise<Component<CliStatus | ExtensionStatus>[]> {
const components: Component<CliStatus | ExtensionStatus>[] = []; const components: Component<CliStatus | ExtensionStatus>[] = [];
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({ components.push({
name: 'nektos/act', name: 'nektos/act',
icon: 'terminal', icon: 'terminal',