From 9a805621033c8c486cbd5a5802470705e1cada75 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 21 May 2024 14:48:40 -0500 Subject: [PATCH] feat: log additional info for json parse errors --- src/commands/cli/artifacts/compare.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/commands/cli/artifacts/compare.ts b/src/commands/cli/artifacts/compare.ts index 0f1a5168..b927c1ee 100644 --- a/src/commands/cli/artifacts/compare.ts +++ b/src/commands/cli/artifacts/compare.ts @@ -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 {