Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/vscode-extension/src/services/ScriptExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Notifications } from './Notifications';
import { StateKeys } from '../constants';
import { evaluateCommand, fileExists, getPlatform } from '../utils';
import { Extension } from './Extension';
import { exec } from 'child_process';
import { execFile } from 'child_process';
import { Logger } from './Logger';
import { StateManager } from './StateManager';
import { Config, Action, Step } from '@demotime/common';
Expand Down Expand Up @@ -58,8 +58,8 @@ export class ScriptExecutor {
command = `${command} -File`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, execFile treats inline args as part of the executable. Appending -File to command makes it look for an exe named "powershell -File", causing ENOENT. Consider keeping command as "powershell" and putting -File in args (e.g., ["-File", scriptPath.fsPath]).

-          command = `${command} -File`;
-
-        const args = [scriptPath.fsPath];
+
+        const args = platform === 'windows' && command.toLowerCase() === 'powershell'
+          ? ['-File', scriptPath.fsPath]
+          : [scriptPath.fsPath];

🚀 Want me to fix this? Reply ex: "fix it for me".

}

const fullScript = `${command} "${scriptPath.fsPath}"`;
const output = await ScriptExecutor.executeScriptAsync(fullScript, wsPath.uri.fsPath);
const args = [scriptPath.fsPath];
const output = await ScriptExecutor.executeScriptAsync(command, args, wsPath.uri.fsPath);
Logger.info(`Step ID: ${id} - Output: ${output}`);

if (output) {
Expand All @@ -77,7 +77,7 @@ export class ScriptExecutor {
*/
public static async executeScriptAsync(fullScript: string, wsPath: string): Promise<string> {
return new Promise((resolve, reject) => {
exec(fullScript, { cwd: wsPath }, (error, stdout) => {
execFile(command, args, { cwd: wsPath }, (error, stdout) => {
if (error) {
Logger.error(error.message);
reject(error.message);
Expand Down