mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
* New method for handling stdin. Bypass Ink, and output to stdout. Makes the CLI work like a typical Unix application when called with piped input. * Fixing a few post-merge errors. * Format code. * Clean up lint and format errors.
28 lines
541 B
TypeScript
28 lines
541 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
export async function readStdin(): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
let data = '';
|
|
process.stdin.setEncoding('utf8');
|
|
|
|
process.stdin.on('readable', () => {
|
|
let chunk;
|
|
while ((chunk = process.stdin.read()) !== null) {
|
|
data += chunk;
|
|
}
|
|
});
|
|
|
|
process.stdin.on('end', () => {
|
|
resolve(data);
|
|
});
|
|
|
|
process.stdin.on('error', (err) => {
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|