mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-30 06:12:03 +00:00
fix: Resolve windows npx spawn errors
This commit is contained in:
@@ -31,7 +31,12 @@ fi
|
|||||||
|
|
||||||
# Ensure common system paths are in PATH (for systems without nvm)
|
# Ensure common system paths are in PATH (for systems without nvm)
|
||||||
# This helps find node/npm installed via Homebrew, system packages, etc.
|
# This helps find node/npm installed via Homebrew, system packages, etc.
|
||||||
export PATH="$PATH:/usr/local/bin:/opt/homebrew/bin:/usr/bin"
|
if [ -n "$WINDIR" ]; then
|
||||||
|
export PATH="$PATH:/c/Program Files/nodejs:/c/Program Files (x86)/nodejs"
|
||||||
|
export PATH="$PATH:$APPDATA/npm:$LOCALAPPDATA/Programs/nodejs"
|
||||||
|
else
|
||||||
|
export PATH="$PATH:/usr/local/bin:/opt/homebrew/bin:/usr/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
# Run lint-staged - works with or without nvm
|
# Run lint-staged - works with or without nvm
|
||||||
# Prefer npx, fallback to npm exec, both work with system-installed Node.js
|
# Prefer npx, fallback to npm exec, both work with system-installed Node.js
|
||||||
|
|||||||
@@ -730,7 +730,7 @@ export class OpencodeProvider extends CliProvider {
|
|||||||
|
|
||||||
if (this.detectedStrategy === 'npx') {
|
if (this.detectedStrategy === 'npx') {
|
||||||
// NPX strategy: execute npx with opencode-ai package
|
// NPX strategy: execute npx with opencode-ai package
|
||||||
command = 'npx';
|
command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
||||||
args = ['opencode-ai@latest', 'models'];
|
args = ['opencode-ai@latest', 'models'];
|
||||||
opencodeLogger.debug(`Executing: ${command} ${args.join(' ')}`);
|
opencodeLogger.debug(`Executing: ${command} ${args.join(' ')}`);
|
||||||
} else if (this.useWsl && this.wslCliPath) {
|
} else if (this.useWsl && this.wslCliPath) {
|
||||||
@@ -751,6 +751,8 @@ export class OpencodeProvider extends CliProvider {
|
|||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
|
// Use shell on Windows for .cmd files
|
||||||
|
shell: process.platform === 'win32' && command.endsWith('.cmd'),
|
||||||
});
|
});
|
||||||
|
|
||||||
opencodeLogger.debug(
|
opencodeLogger.debug(
|
||||||
@@ -963,7 +965,7 @@ export class OpencodeProvider extends CliProvider {
|
|||||||
|
|
||||||
if (this.detectedStrategy === 'npx') {
|
if (this.detectedStrategy === 'npx') {
|
||||||
// NPX strategy
|
// NPX strategy
|
||||||
command = 'npx';
|
command = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
||||||
args = ['opencode-ai@latest', 'auth', 'list'];
|
args = ['opencode-ai@latest', 'auth', 'list'];
|
||||||
opencodeLogger.debug(`Executing: ${command} ${args.join(' ')}`);
|
opencodeLogger.debug(`Executing: ${command} ${args.join(' ')}`);
|
||||||
} else if (this.useWsl && this.wslCliPath) {
|
} else if (this.useWsl && this.wslCliPath) {
|
||||||
@@ -984,6 +986,8 @@ export class OpencodeProvider extends CliProvider {
|
|||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
|
// Use shell on Windows for .cmd files
|
||||||
|
shell: process.platform === 'win32' && command.endsWith('.cmd'),
|
||||||
});
|
});
|
||||||
|
|
||||||
opencodeLogger.debug(
|
opencodeLogger.debug(
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ export async function* spawnJSONLProcess(options: SubprocessOptions): AsyncGener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// On Windows, .cmd files must be run through shell (cmd.exe)
|
// On Windows, .cmd files must be run through shell (cmd.exe)
|
||||||
const needsShell = process.platform === 'win32' && command.toLowerCase().endsWith('.cmd');
|
const needsShell =
|
||||||
|
process.platform === 'win32' &&
|
||||||
|
(command.toLowerCase().endsWith('.cmd') || command === 'npx' || command === 'npm');
|
||||||
|
|
||||||
const childProcess: ChildProcess = spawn(command, args, {
|
const childProcess: ChildProcess = spawn(command, args, {
|
||||||
cwd,
|
cwd,
|
||||||
@@ -199,7 +201,9 @@ export async function spawnProcess(options: SubprocessOptions): Promise<Subproce
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// On Windows, .cmd files must be run through shell (cmd.exe)
|
// On Windows, .cmd files must be run through shell (cmd.exe)
|
||||||
const needsShell = process.platform === 'win32' && command.toLowerCase().endsWith('.cmd');
|
const needsShell =
|
||||||
|
process.platform === 'win32' &&
|
||||||
|
(command.toLowerCase().endsWith('.cmd') || command === 'npx' || command === 'npm');
|
||||||
|
|
||||||
const childProcess = spawn(command, args, {
|
const childProcess = spawn(command, args, {
|
||||||
cwd,
|
cwd,
|
||||||
|
|||||||
Reference in New Issue
Block a user