Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
feat: update --json command without --verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
vamsimundra committed Jun 23, 2021
1 parent e00e2ca commit 00827c3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,18 @@ interface VersionDetail {
cliVersion: string;
architecture: string;
nodeVersion: string;
pluginVersions: string[];
osVersion: string;
pluginVersions?: string[];
osVersion?: string;
}

class SfdxMain extends Main {
// Function which returns Version object which includes cli version, plugin versions, OS and its version.
protected getVersionDetail(): VersionDetail {
protected getVersionDetail(isVerbose: boolean): VersionDetail {
const versions = this.config.userAgent.split(' ');
const cliVersion: string = versions[0];
const architecture: string = versions[1];
const nodeVersion: string = versions[2];
if (!isVerbose) return { cliVersion, architecture, nodeVersion };
const pluginVersion: string = exec('sfdx plugins --core', {
silent: true,
}).toString();
Expand All @@ -150,7 +151,7 @@ class SfdxMain extends Main {
this.log(`\n Architecture: \n\t${versionDetails.architecture}`);
this.log(`\n Node Version : \n\t${versionDetails.nodeVersion}`);
this.log('\n Plugin Version: ');
versionDetails.pluginVersions.forEach((plugin) => {
versionDetails.pluginVersions?.forEach((plugin) => {
this.log(`\t${plugin}`);
});
this.log(`\n OS and Version: \n\t${versionDetails.osVersion}`);
Expand All @@ -164,7 +165,7 @@ class SfdxMain extends Main {
if (!options.has('--verbose') && !options.has('--json')) {
this.log(this.config.userAgent);
} else {
const versionDetails = this.getVersionDetail();
const versionDetails = this.getVersionDetail(options.has('--verbose'));
this.printVersionDetails(versionDetails, options.has('--json'));
}
return this.exit(0);
Expand Down

0 comments on commit 00827c3

Please sign in to comment.