Skip to content

Commit

Permalink
Added guard against undefined branchBuilds and fixed releases format …
Browse files Browse the repository at this point in the history
…in json output
  • Loading branch information
cb1kenobi committed Jun 28, 2022
1 parent ba28174 commit bd05fbf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/commands/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,23 @@ async function list(logger, config, cli) {

const obj = {
activeSDK,
branch: branchBuilds.length ? {
branch: branchBuilds?.length ? {
[cli.argv.branch]: branchBuilds
} : {},
branches,
branches: {
defaultBranch: 'master',
branches: branches || []
},
defaultInstallLocation,
installLocations: locations,
installed: vers.reduce((obj, v) => {
obj[v] = sdks[v].path;
return obj;
}, {}),
releases,
releases: releases && releases.reduce((obj, { name, assets }) => {
obj[name] = assets.find(a => a.os === os).url;
return obj;
}, {}) || {},
sdks
};

Expand Down Expand Up @@ -274,7 +280,7 @@ ${r.type !== 'ga' ? ' [unstable]'.grey : i++ === 0 ? ' [latest stable]'.green
logger.log(`Run '${`${cli.argv.$} sdk --branches`.cyan}' for a list of available branches.\n`);
} else {
logger.log(`'${cli.argv.branch}' Branch Builds:`);
if (branchBuilds.length) {
if (branchBuilds?.length) {
for (const b of branchBuilds) {
const dt = Intl.DateTimeFormat('en-US', { dateStyle: 'short' }).format(new Date(b.date));
logger.log(` ${b.name.cyan}\
Expand Down

0 comments on commit bd05fbf

Please sign in to comment.