Skip to content

Commit 7b37432

Browse files
authored
feat: log additional info for json parse errors (#1093)
1 parent d79a169 commit 7b37432

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/commands/cli/artifacts/compare.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ const messages = Messages.loadMessages('@salesforce/plugin-release-management',
2929

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

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

0 commit comments

Comments
 (0)