fix(windows): hide terminal windows when spawning child processes
This commit is contained in:
@@ -17,18 +17,14 @@ import { join } from 'path';
|
|||||||
import { homedir } from 'os';
|
import { homedir } from 'os';
|
||||||
import { createRequire } from 'module';
|
import { createRequire } from 'module';
|
||||||
|
|
||||||
// CRITICAL: Always use marketplace directory for ALL operations
|
|
||||||
// This script may run from the cache directory (plugin/scripts/) but must
|
|
||||||
// operate on the marketplace directory where package.json and node_modules live.
|
|
||||||
// This ensures cross-platform compatibility and avoids cache directory confusion.
|
|
||||||
const MARKETPLACE_ROOT = join(homedir(), '.claude', 'plugins', 'marketplaces', 'thedotmack');
|
|
||||||
|
|
||||||
// Use MARKETPLACE_ROOT for all paths - this script can be deployed anywhere
|
// CRITICAL: Always use marketplace directory for npm install and PM2/ecosystem
|
||||||
// but always operates on the marketplace directory
|
// This script may run from cache directory (plugin/) which has no package.json
|
||||||
const PLUGIN_ROOT = MARKETPLACE_ROOT;
|
// The marketplace root is the canonical location with package.json and node_modules
|
||||||
const PACKAGE_JSON_PATH = join(PLUGIN_ROOT, 'package.json');
|
const MARKETPLACE_ROOT = join(homedir(), '.claude', 'plugins', 'marketplaces', 'thedotmack');
|
||||||
const VERSION_MARKER_PATH = join(PLUGIN_ROOT, '.install-version');
|
const PACKAGE_JSON_PATH = join(MARKETPLACE_ROOT, 'package.json');
|
||||||
const NODE_MODULES_PATH = join(PLUGIN_ROOT, 'node_modules');
|
const VERSION_MARKER_PATH = join(MARKETPLACE_ROOT, '.install-version');
|
||||||
|
const NODE_MODULES_PATH = join(MARKETPLACE_ROOT, 'node_modules');
|
||||||
const BETTER_SQLITE3_PATH = join(NODE_MODULES_PATH, 'better-sqlite3');
|
const BETTER_SQLITE3_PATH = join(NODE_MODULES_PATH, 'better-sqlite3');
|
||||||
|
|
||||||
// Colors for output
|
// Colors for output
|
||||||
@@ -264,7 +260,7 @@ async function runNpmInstall() {
|
|||||||
|
|
||||||
// Run npm install silently
|
// Run npm install silently
|
||||||
execSync(command, {
|
execSync(command, {
|
||||||
cwd: PLUGIN_ROOT,
|
cwd: MARKETPLACE_ROOT,
|
||||||
stdio: 'pipe', // Silent output unless error
|
stdio: 'pipe', // Silent output unless error
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,6 +6,15 @@
|
|||||||
* See src/services/worker/README.md for architecture details.
|
* See src/services/worker/README.md for architecture details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Windows terminal window fix: Set process.type to trick MCP SDK into enabling windowsHide
|
||||||
|
// The SDK checks `process.type === 'renderer'` (Electron detection) before setting windowsHide.
|
||||||
|
// By setting process.type, the SDK's isElectron() check becomes truthy on Windows, hiding
|
||||||
|
// terminal windows when spawning uvx/python processes for Chroma MCP server.
|
||||||
|
// The type is sometimes not present resulting in the check being false. Setting it like this fixes it
|
||||||
|
if (process.platform === 'win32' && !process.type) {
|
||||||
|
(process as any).type = 'renderer';
|
||||||
|
}
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ function execGit(command: string): string {
|
|||||||
return execSync(`git ${command}`, {
|
return execSync(`git ${command}`, {
|
||||||
cwd: INSTALLED_PLUGIN_PATH,
|
cwd: INSTALLED_PLUGIN_PATH,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: 30000
|
timeout: 30000,
|
||||||
|
windowsHide: true
|
||||||
}).trim();
|
}).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +48,8 @@ function execShell(command: string, timeoutMs: number = 60000): string {
|
|||||||
return execSync(command, {
|
return execSync(command, {
|
||||||
cwd: INSTALLED_PLUGIN_PATH,
|
cwd: INSTALLED_PLUGIN_PATH,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
timeout: timeoutMs
|
timeout: timeoutMs,
|
||||||
|
windowsHide: true
|
||||||
}).trim();
|
}).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -89,7 +89,8 @@ export function getCurrentProjectName(): string {
|
|||||||
const gitRoot = execSync('git rev-parse --show-toplevel', {
|
const gitRoot = execSync('git rev-parse --show-toplevel', {
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
stdio: ['pipe', 'pipe', 'ignore']
|
stdio: ['pipe', 'pipe', 'ignore'],
|
||||||
|
windowsHide: true
|
||||||
}).trim();
|
}).trim();
|
||||||
return basename(gitRoot);
|
return basename(gitRoot);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user