From c943ea1c436b836385bc3b653c3d58b63ab3e25e Mon Sep 17 00:00:00 2001 From: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:08:12 +0000 Subject: [PATCH] fix: printCommand test --- mod.ts | 16 +++++++++------- src/command.ts | 7 ++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/mod.ts b/mod.ts index 42f230a..87ecb77 100644 --- a/mod.ts +++ b/mod.ts @@ -415,17 +415,17 @@ export interface $BuiltInProperties { * Sets the logger used for info logging. * @default console.error */ - setInfoLogger(logger: (args: any[]) => void): void; + setInfoLogger(logger: (...args: any[]) => void): void; /** * Sets the logger used for warn logging. * @default console.error */ - setWarnLogger(logger: (args: any[]) => void): void; + setWarnLogger(logger: (...args: any[]) => void): void; /** * Sets the logger used for error logging. * @default console.error */ - setErrorLogger(logger: (args: any[]) => void): void; + setErrorLogger(logger: (...args: any[]) => void): void; /** * Mutates the internal command builder to print the command text by * default before executing commands instead of needing to build a @@ -719,18 +719,20 @@ function build$FromState(state: $State void) { + setInfoLogger(logger: (...args: any[]) => void) { state.infoLogger.setValue(logger); }, - setWarnLogger(logger: (args: any[]) => void) { + setWarnLogger(logger: (...args: any[]) => void) { state.warnLogger.setValue(logger); }, - setErrorLogger(logger: (args: any[]) => void) { + setErrorLogger(logger: (...args: any[]) => void) { state.errorLogger.setValue(logger); // also update the logger used for the print command const commandBuilder = state.commandBuilder.getValue(); - commandBuilder.setPrintCommandLogger(logger); + commandBuilder.setPrintCommandLogger( + (cmd) => logger(colors.white(">"), colors.blue(cmd)), + ); state.commandBuilder.setValue(commandBuilder); }, setPrintCommand(value: boolean) { diff --git a/src/command.ts b/src/command.ts index fe1733d..7314493 100644 --- a/src/command.ts +++ b/src/command.ts @@ -106,11 +106,8 @@ export class CommandBuilder implements PromiseLike { commands: { ...builtInCommands }, exportEnv: false, printCommand: false, - printCommandLogger: new LoggerTreeBox((cmd) => - console.error( - colors.white(">"), - colors.blue(cmd), - ) + printCommandLogger: new LoggerTreeBox( + (cmd) => console.error(colors.white(">"), colors.blue(cmd)), ), timeout: undefined,