diff --git a/src/sfCommand.ts b/src/sfCommand.ts index cf460eae..660d3300 100644 --- a/src/sfCommand.ts +++ b/src/sfCommand.ts @@ -308,6 +308,14 @@ export abstract class SfCommand extends Command { this.ux.styledHeader(text); } + // eslint-disable-next-line class-methods-use-this + public logJson(json: AnyJson | unknown): void { + // If `--json` is enabled, then the ux instance on the class will disable output, which + // means that the logJson method will not output anything. So, we need to create a new + // instance of the ux class that does not have output disabled in order to log the json. + new Ux().styledJSON(json as AnyJson); + } + /** * Prompt user for information. See https://www.npmjs.com/package/inquirer for more. * @@ -410,14 +418,6 @@ export abstract class SfCommand extends Command { }; } - // eslint-disable-next-line class-methods-use-this - protected logJson(json: AnyJson | unknown): void { - // If `--json` is enabled, then the ux instance on the class will disable output, which - // means that the logJson method will not output anything. So, we need to create a new - // instance of the ux class that does not have output disabled in order to log the json. - new Ux().styledJSON(json as AnyJson); - } - // eslint-disable-next-line class-methods-use-this protected async assignProject(): Promise { try { diff --git a/src/stubUx.ts b/src/stubUx.ts index 73f11087..88cab99c 100644 --- a/src/stubUx.ts +++ b/src/stubUx.ts @@ -24,6 +24,7 @@ export function stubUx(sandbox: SinonSandbox) { export function stubSfCommandUx(sandbox: SinonSandbox) { return { log: sandbox.stub(SfCommand.prototype, 'log'), + logJson: sandbox.stub(SfCommand.prototype, 'logJson'), logToStderr: sandbox.stub(SfCommand.prototype, 'logToStderr'), logSuccess: sandbox.stub(SfCommand.prototype, 'logSuccess'), logSensitive: sandbox.stub(SfCommand.prototype, 'logSensitive'),