Skip to content

Commit 1223ccc

Browse files
committed
WIP
1 parent d013802 commit 1223ccc

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

genkit-tools/cli/src/commands/ui-start.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ async function startAndWaitUntilHealthy(
152152
);
153153
}
154154

155-
// Handles spaces in the command path
156-
const command = `"${spawnConfig.command}"`;
157-
const args = spawnConfig.args.map((arg) => `"${arg}"`);
158-
159-
logger.debug(`Spawning: ${command} ${args.join(' ')}`);
160-
const child = spawn(command, args, spawnConfig.options);
155+
logger.debug(
156+
`Spawning: ${spawnConfig.command} ${spawnConfig.args.join(' ')}`
157+
);
158+
const child = spawn(
159+
spawnConfig.command,
160+
spawnConfig.args,
161+
spawnConfig.options
162+
);
161163

162164
// Wait for the process to be ready
163165
return new Promise<ChildProcess>((resolve, reject) => {

genkit-tools/cli/src/utils/spawn-config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { type SpawnOptions } from 'child_process';
1818
import { access, constants } from 'fs/promises';
1919
import { SERVER_HARNESS_COMMAND } from '../commands/server-harness';
2020
import { type RuntimeInfo } from './runtime-detector';
21+
import { logger } from '@genkit-ai/tools-common/utils';
2122

2223
/**
2324
* Configuration for spawning a child process
@@ -38,7 +39,11 @@ export interface SpawnConfig {
3839
*/
3940
export async function validateExecutablePath(path: string): Promise<boolean> {
4041
try {
41-
await access(path, constants.F_OK | constants.X_OK);
42+
// Remove surrounding quotes if present (handle quotation)
43+
const normalizedPath = path.startsWith('"') && path.endsWith('"')
44+
? path.slice(1, -1)
45+
: path;
46+
await access(normalizedPath, constants.F_OK | constants.X_OK);
4247
return true;
4348
} catch {
4449
return false;
@@ -91,7 +96,7 @@ export function buildServerHarnessSpawnConfig(
9196
throw new Error('Log path is required');
9297
}
9398

94-
const command = runtime.execPath;
99+
let command = runtime.execPath;
95100
let args: string[];
96101

97102
if (runtime.type === 'compiled-binary') {
@@ -112,6 +117,13 @@ export function buildServerHarnessSpawnConfig(
112117
shell: runtime.platform === 'win32',
113118
};
114119

120+
// Handles spaces in the command and arguments on Windows
121+
logger.debug(`Platform: ${runtime.platform}`);
122+
if (runtime.platform === 'win32') {
123+
command = `"${command}"`;
124+
args = args.map((arg) => `"${arg}"`);
125+
}
126+
115127
return {
116128
command,
117129
args,

0 commit comments

Comments
 (0)