Commit 04333d74 authored by Auto Backup's avatar Auto Backup

fix: Windows use cmd /c to execute commands for .cmd/.bat file support (like npm)

parent 2d79693e
...@@ -143,6 +143,7 @@ function execWithShell(command, shellPath) { ...@@ -143,6 +143,7 @@ function execWithShell(command, shellPath) {
async function executeCommand(command) { async function executeCommand(command) {
try { try {
let parentShell = null; let parentShell = null;
let actualCommand = command;
if (isWindows) { if (isWindows) {
try { try {
...@@ -153,9 +154,13 @@ async function executeCommand(command) { ...@@ -153,9 +154,13 @@ async function executeCommand(command) {
} catch (e) { } catch (e) {
// Ignore error, use default // Ignore error, use default
} }
// Windows: Wrap command with cmd /c to support .cmd and .bat files (like npm)
// pwsh cannot directly execute .cmd files
actualCommand = `cmd /c "${command}"`;
} }
const result = await execWithShell(command, parentShell); const result = await execWithShell(actualCommand, parentShell);
return { success: true, stdout: result.stdout, stderr: result.stderr }; return { success: true, stdout: result.stdout, stderr: result.stderr };
} catch (error) { } catch (error) {
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment