From 4963a1eea8bd88530daa7fec1c1f04a12d2f46a4 Mon Sep 17 00:00:00 2001 From: matt korwel Date: Sat, 5 Jul 2025 08:27:22 -0700 Subject: [PATCH] Mk nohup (#3285) --- integration-tests/run_shell_command.test.js | 13 ++++++++- integration-tests/test-helper.js | 32 +++++++++++++++------ packages/cli/src/gemini.tsx | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/integration-tests/run_shell_command.test.js b/integration-tests/run_shell_command.test.js index 04cc02fa..52aee194 100644 --- a/integration-tests/run_shell_command.test.js +++ b/integration-tests/run_shell_command.test.js @@ -14,7 +14,18 @@ test('should be able to run a shell command', async (t) => { rig.createFile('blah.txt', 'some content'); const prompt = `Can you use ls to list the contexts of the current folder`; - const result = await rig.run(prompt); + const result = rig.run(prompt); + + assert.ok(result.includes('blah.txt')); +}); + +test('should be able to run a shell command via stdin', async (t) => { + const rig = new TestRig(); + rig.setup(t.name); + rig.createFile('blah.txt', 'some content'); + + const prompt = `Can you use ls to list the contexts of the current folder`; + const result = rig.run({ stdin: prompt }); assert.ok(result.includes('blah.txt')); }); diff --git a/integration-tests/test-helper.js b/integration-tests/test-helper.js index eb598bd9..7acdc7aa 100644 --- a/integration-tests/test-helper.js +++ b/integration-tests/test-helper.js @@ -47,14 +47,30 @@ export class TestRig { execSync('sync', { cwd: this.testDir }); } - run(prompt, ...args) { - const output = execSync( - `node ${this.bundlePath} --yolo --prompt "${prompt}" ${args.join(' ')}`, - { - cwd: this.testDir, - encoding: 'utf-8', - }, - ); + run(promptOrOptions, ...args) { + let command = `node ${this.bundlePath} --yolo`; + const execOptions = { + cwd: this.testDir, + encoding: 'utf-8', + }; + + if (typeof promptOrOptions === 'string') { + command += ` --prompt "${promptOrOptions}"`; + } else if ( + typeof promptOrOptions === 'object' && + promptOrOptions !== null + ) { + if (promptOrOptions.prompt) { + command += ` --prompt "${promptOrOptions.prompt}"`; + } + if (promptOrOptions.stdin) { + execOptions.input = promptOrOptions.stdin; + } + } + + command += ` ${args.join(' ')}`; + + const output = execSync(command, execOptions); if (env.KEEP_OUTPUT === 'true') { const testId = `${env.TEST_FILE_NAME.replace( diff --git a/packages/cli/src/gemini.tsx b/packages/cli/src/gemini.tsx index 9ad481fc..7bd062ac 100644 --- a/packages/cli/src/gemini.tsx +++ b/packages/cli/src/gemini.tsx @@ -184,7 +184,7 @@ export async function main() { } // If not a TTY, read from stdin // This is for cases where the user pipes input directly into the command - if (!process.stdin.isTTY) { + if (!process.stdin.isTTY && !input) { input += await readStdin(); } if (!input) {