Merge pull request #525 from devchat-ai/short_log_for_command_line

chore: Truncate long commands in spawnAsync logger
This commit is contained in:
boob.yang 2024-05-18 16:04:00 +08:00 committed by GitHub
commit f244c8f924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,7 +62,12 @@ export class CommandRun {
public async spawnAsync(command: string, args: string[], options: object, onData: ((data: string) => void) | undefined, onError: ((data: string) => void) | undefined, onOutputFile: ((command: string, stdout: string, stderr: string) => string) | undefined, outputFile: string | undefined): Promise<CommandResult> {
return new Promise((resolve, reject) => {
logger.channel()?.debug(`Running command: ${command} ${args.join(' ')}`);
const maxLength = 150;
const commandAndArgs = `${command} ${args.join(' ')}`;
const truncatedCommandAndArgs = commandAndArgs.length > maxLength ? commandAndArgs.substring(0, maxLength) + '...' : commandAndArgs;
logger.channel()?.debug(`Running command: ${truncatedCommandAndArgs}`);
logger.channel()?.trace(`Running command: ${command} ${args.join(' ')}`);
this._input = "";
const argsNew: string[] = args.map((arg) => {
if (arg.trim()[0] === '$') {