Skip to content

Commit

Permalink
fix: remove duplicated risks (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
azu authored Aug 29, 2023
1 parent 9f17539 commit e2df8a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ni.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function ni-assertPackageBySocket() {
--url "https://api.socket.dev/v0/npm/${pkg}/${version}/issues" \
--header 'accept: application/json' \
--header "authorization: Basic ${bearerToken}" \
| jq -r '[.[] | select(.value.category == "supplyChainRisk") | {severity: .value.severity, type: .type}] | sort_by([.severity == "low", .severity == "middle", .severity == "high", .severity == "critical"]) | map("* [\(.severity)] \(.type) - https://socket.dev/npm/issue/\(.type)") | join("\n")')
| jq -r '[.[] | select(.value.category == "supplyChainRisk") | {severity: .value.severity, type: .type}] | sort_by(.severity) | map("* [\(.severity)] \(.type) - https://socket.dev/npm/issue/\(.type)") | unique | join("\n")')
# jq filter is following logic
# ```js
# const message = test.filter((item) => {
Expand All @@ -155,6 +155,9 @@ function ni-assertPackageBySocket() {
# }).map((item) => {
# // [value.severity] [type] - https://socket.dev/npm/issue/${type}
# return `* ${item.value.severity} ${item.type} - https://socket.dev/npm/issue/${item.type}`;
# }).filter((item, array) => {
# // remove duplicated
# return array.indexOf(item) === array.lastIndexOf(item);
# });
# ```
echo -e "\033[31m$riskMessage\033[0m"
Expand Down

0 comments on commit e2df8a1

Please sign in to comment.