Skip to content

Commit

Permalink
fix: pipe stdin from genkit start process (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelgj authored Nov 9, 2024
1 parent 59e2cab commit 4071754
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
10 changes: 4 additions & 6 deletions genkit-tools/cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ export const start = new Command('start')
env: { ...process.env, GENKIT_ENV: 'dev' },
});

appProcess.stdout?.on('data', (data) => {
process.stdout.write(data);
});
appProcess.stderr?.on('data', (data) => {
process.stderr.write(data);
});
appProcess.stderr?.pipe(process.stderr);
appProcess.stdout?.pipe(process.stdout);
process.stdin?.pipe(appProcess.stdin);

appProcess.on('error', (error): void => {
console.log(`Error in app process: ${error}`);
reject(error);
Expand Down
23 changes: 0 additions & 23 deletions genkit-tools/common/src/plugin/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import { execSync } from 'child_process';
import * as clc from 'colorette';
import { createInterface } from 'readline/promises';
import { z } from 'zod';

const SupportedFlagValuesSchema = z.union([
Expand Down Expand Up @@ -67,11 +66,6 @@ export type SpecialAction = keyof z.infer<typeof ToolPluginSubCommandsSchema>;

const SEPARATOR = '===========================';

const readline = createInterface({
input: process.stdin,
output: process.stdout,
});

/**
* Executes the command given, returning the contents of STDOUT.
*
Expand All @@ -91,20 +85,3 @@ export function cliCommand(command: string, options?: string): void {

console.log(`${SEPARATOR}\n`);
}

/**
* Utility function to prompt user for sensitive operations.
*/
export async function promptContinue(
message: string,
dfault: boolean
): Promise<boolean> {
console.log(message);
const opts = dfault ? 'Y/n' : 'y/N';
const r = await readline.question(`${clc.bold('Continue')}? (${opts}) `);
if (r === '') {
return dfault;
}

return r.toLowerCase() === 'y';
}

0 comments on commit 4071754

Please sign in to comment.