Skip to content

Commit d58786f

Browse files
authored
feat: handle non-json from npm view (#1099)
* feat: handle non-json responses from npm view * docs: npm bug link * docs: correct bug link
1 parent 2cf867b commit d58786f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/commands/cli/artifacts/compare.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ const messages = Messages.loadMessages('@salesforce/plugin-release-management',
3030
async function getOwnerAndRepo(plugin: string): Promise<{ owner: string; repo: string }> {
3131
const result = await exec(`npm view ${plugin} repository.url --json`);
3232
try {
33-
const [owner, repo] = (JSON.parse(result.stdout) as string)
33+
const [owner, repo] = (
34+
result.stdout.startsWith('"')
35+
? // it returned json (a string in quotes ex: "git+https://github.com/salesforcecli/plugin-org.git")
36+
(JSON.parse(result.stdout) as string)
37+
: // it returned non-json (just the string) https://github.com/npm/cli/issues/7537
38+
result.stdout
39+
)
3440
.replace('git+https://github.com/', '')
3541
.replace('.git', '')
3642
.split('/');

0 commit comments

Comments
 (0)