Skip to content

Commit

Permalink
feat: log additional info for json parse errors (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored May 21, 2024
1 parent d79a169 commit 7b37432
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/commands/cli/artifacts/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ const messages = Messages.loadMessages('@salesforce/plugin-release-management',

async function getOwnerAndRepo(plugin: string): Promise<{ owner: string; repo: string }> {
const result = await exec(`npm view ${plugin} repository.url --json`);
const parsed = (JSON.parse(result.stdout) as string)
.replace('git+https://github.com/', '')
.replace('.git', '')
.split('/');
return { owner: parsed[0], repo: parsed[1] };
try {
const [owner, repo] = (JSON.parse(result.stdout) as string)
.replace('git+https://github.com/', '')
.replace('.git', '')
.split('/');
return { owner, repo };
} catch (e) {
throw SfError.create({ message: `Error getting owner and repo for ${plugin}`, cause: e, data: result });
}
}

async function getNpmVersions(plugin: string): Promise<string[]> {
Expand Down

0 comments on commit 7b37432

Please sign in to comment.