fix: add Windows compatibility for PM2 detection

- Use .cmd extension for PM2 on Windows (pm2.cmd vs pm2)
- Add shell: true to execSync for proper path quoting on Windows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Dmitry Guyvoronsky
2025-11-24 13:27:46 -08:00
parent 6c9a8d1dca
commit 2a2206d886
2 changed files with 14 additions and 6 deletions
+7 -3
View File
@@ -264,14 +264,18 @@ async function main() {
// Try to start the PM2 worker after fresh install
try {
log('🚀 Starting worker service...', colors.cyan);
const localPm2 = join(NODE_MODULES_PATH, '.bin', 'pm2');
const pm2Command = existsSync(localPm2) ? localPm2 : 'pm2';
// On Windows, PM2 executable is pm2.cmd, not pm2
const localPm2Base = join(NODE_MODULES_PATH, '.bin', 'pm2');
const localPm2Cmd = process.platform === 'win32' ? localPm2Base + '.cmd' : localPm2Base;
const pm2Command = existsSync(localPm2Cmd) ? localPm2Cmd : 'pm2';
const ecosystemPath = join(PLUGIN_ROOT, 'ecosystem.config.cjs');
// shell: true required for Windows to handle quoted paths correctly
execSync(`"${pm2Command}" start "${ecosystemPath}"`, {
cwd: PLUGIN_ROOT,
stdio: 'pipe',
encoding: 'utf-8'
encoding: 'utf-8',
shell: true
});
log('✅ Worker service started', colors.green);