Skip to content

Commit 5cf2308

Browse files
committed
Add link to issue
1 parent d0626a9 commit 5cf2308

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/commands/info/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues }, spin
175175
const issueSummary = formatSeverityCount(severityCount)
176176
console.log('\n')
177177
spinner[strict ? 'fail' : 'succeed'](`Package has these issues: ${issueSummary}`)
178-
formatPackageIssuesDetails(data)
178+
formatPackageIssuesDetails(data, outputMarkdown)
179179
} else {
180180
console.log('\n')
181181
spinner.succeed('Package has no issues')
@@ -197,9 +197,10 @@ async function fetchPackageData (pkgName, pkgVersion, { includeAllIssues }, spin
197197

198198
/**
199199
* @param {import('@socketsecurity/sdk').SocketSdkReturnType<'getIssuesByNPMPackage'>["data"]} packageData
200+
* @param {boolean} outputMarkdown
200201
* @returns {void[]}
201202
*/
202-
function formatPackageIssuesDetails (packageData) {
203+
function formatPackageIssuesDetails (packageData, outputMarkdown) {
203204
const issueDetails = packageData.filter(d => d.value?.severity === 'high' || d.value?.severity === 'critical')
204205
const uniqueIssues = issueDetails.reduce((/** @type {{ [key: string]: number }} */ acc, issue) => {
205206
const { type } = issue
@@ -212,11 +213,13 @@ function formatPackageIssuesDetails (packageData) {
212213
}
213214
return acc
214215
}, {})
216+
const format = new ChalkOrMarkdown(!!outputMarkdown)
215217
return Object.keys(uniqueIssues).map(issue => {
218+
const issueWithLink = format.hyperlink(`${issue}`, `https://socket.dev/npm/issue/${issue}`, { fallbackToUrl: true })
216219
if (uniqueIssues[issue] === 1) {
217-
return console.log(`- ${issue}`)
220+
return console.log(`- ${issueWithLink}`)
218221
}
219-
return console.log(`- ${issue}: ${uniqueIssues[issue]}`)
222+
return console.log(`- ${issueWithLink}: ${uniqueIssues[issue]}`)
220223
})
221224
}
222225

0 commit comments

Comments
 (0)