Skip to content

Commit

Permalink
fix: printCommand test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Dec 18, 2023
1 parent 336eca6 commit c943ea1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 9 additions & 7 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,17 @@ export interface $BuiltInProperties<TExtras extends ExtrasObject = {}> {
* 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
Expand Down Expand Up @@ -719,18 +719,20 @@ function build$FromState<TExtras extends ExtrasObject = {}>(state: $State<TExtra
state.infoLogger.getValue()(...data);
}, opts);
},
setInfoLogger(logger: (args: any[]) => 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) {
Expand Down
7 changes: 2 additions & 5 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,8 @@ export class CommandBuilder implements PromiseLike<CommandResult> {
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,
Expand Down

0 comments on commit c943ea1

Please sign in to comment.