Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pipe stdin from genkit start process #1224

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}
Loading