Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add stderr method #441

Merged
merged 9 commits into from Jul 15, 2022
8 changes: 7 additions & 1 deletion src/command.ts
Expand Up @@ -201,12 +201,18 @@ export default abstract class Command {

log(message = '', ...args: any[]): void {
if (!this.jsonEnabled()) {
// tslint:disable-next-line strict-type-predicates
message = typeof message === 'string' ? message : inspect(message)
process.stdout.write(format(message, ...args) + '\n')
}
}

logToStderr(message = '', ...args: any[]): void {
if (!this.jsonEnabled()) {
message = typeof message === 'string' ? message : inspect(message)
process.stderr.write(format(message, ...args) + '\n')
}
}

public jsonEnabled(): boolean {
return this.ctor.enableJsonFlag && this.argv.includes('--json')
}
Expand Down