diff --git a/mod.ts b/mod.ts index 62d03b5..9def0af 100644 --- a/mod.ts +++ b/mod.ts @@ -434,17 +434,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 @@ -736,18 +736,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 65c4818..b4d8046 100644 --- a/src/command.ts +++ b/src/command.ts @@ -142,8 +142,10 @@ export class CommandBuilder implements PromiseLike { commands: { ...builtInCommands }, exportEnv: false, printCommand: false, - // deno-lint-ignore no-console - printCommandLogger: new LoggerTreeBox(console.error), + printCommandLogger: new LoggerTreeBox( + // deno-lint-ignore no-console + (cmd) => console.error(colors.white(">"), colors.blue(cmd)), + ), timeout: undefined, signal: undefined, }; @@ -681,7 +683,7 @@ export function parseAndSpawnCommand(state: CommandBuilderState) { } if (state.printCommand) { - state.printCommandLogger.getValue()(colors.white(">"), colors.blue(state.command.text)); + state.printCommandLogger.getValue()(state.command.text); } const disposables: Disposable[] = [];