Skip to content

Commit

Permalink
feat: handle non-json from npm view (#1099)
Browse files Browse the repository at this point in the history
* feat: handle non-json responses from npm view

* docs: npm bug link

* docs: correct bug link
  • Loading branch information
mshanemc committed May 29, 2024
1 parent 2cf867b commit d58786f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/commands/cli/artifacts/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ 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`);
try {
const [owner, repo] = (JSON.parse(result.stdout) as string)
const [owner, repo] = (
result.stdout.startsWith('"')
? // it returned json (a string in quotes ex: "git+https://github.com/salesforcecli/plugin-org.git")
(JSON.parse(result.stdout) as string)
: // it returned non-json (just the string) https://github.com/npm/cli/issues/7537
result.stdout
)
.replace('git+https://github.com/', '')
.replace('.git', '')
.split('/');
Expand Down

0 comments on commit d58786f

Please sign in to comment.