Skip to content

Commit 98050ac

Browse files
committed
Use opts instead of options_
1 parent 0210dce commit 98050ac

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/shadow/npm/arborist-helpers.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ export type GetAlertsMapFromArboristOptions = {
179179

180180
export async function getAlertsMapFromArborist(
181181
arb: ArboristInstance,
182-
options_?: GetAlertsMapFromArboristOptions | undefined,
182+
options?: GetAlertsMapFromArboristOptions | undefined,
183183
): Promise<AlertsByPurl> {
184-
const options = {
184+
const opts = {
185185
__proto__: null,
186186
consolidate: false,
187187
include: undefined,
188188
nothrow: false,
189-
...options_,
189+
...options,
190190
} as GetAlertsMapFromArboristOptions
191191

192-
options.include = {
192+
opts.include = {
193193
__proto__: null,
194194
// Leave 'actions' unassigned so it can be given a default value in
195195
// subsequent functions where `options` is passed.
@@ -200,12 +200,12 @@ export async function getAlertsMapFromArborist(
200200
existing: false,
201201
unfixable: true,
202202
upgradable: false,
203-
...options.include,
203+
...opts.include,
204204
} as AlertIncludeFilter
205205

206206
const needInfoOn = getDetailsFromDiff(arb.diff, {
207207
include: {
208-
unchanged: options.include.existing,
208+
unchanged: opts.include.existing,
209209
},
210210
})
211211

src/utils/alerts-map.mts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ export type GetAlertsMapFromPurlsOptions = {
4343

4444
export async function getAlertsMapFromPurls(
4545
purls: string[] | readonly string[],
46-
options_?: GetAlertsMapFromPurlsOptions | undefined,
46+
options?: GetAlertsMapFromPurlsOptions | undefined,
4747
): Promise<AlertsByPurl> {
48-
const options = {
48+
const opts = {
4949
__proto__: null,
5050
consolidate: false,
5151
include: undefined,
5252
nothrow: false,
53-
...options_,
53+
...options,
5454
} as GetAlertsMapFromPurlsOptions
5555

56-
options.include = {
56+
opts.include = {
5757
__proto__: null,
5858
// Leave 'actions' unassigned so it can be given a default value in
5959
// subsequent functions where `options` is passed.
@@ -64,11 +64,9 @@ export async function getAlertsMapFromPurls(
6464
existing: false,
6565
unfixable: true,
6666
upgradable: false,
67-
...options.include,
67+
...opts.include,
6868
} as AlertIncludeFilter
6969

70-
const { spinner } = options
71-
7270
const uniqPurls = arrayUnique(purls)
7371
debugDir('silly', { purls: uniqPurls })
7472

@@ -79,6 +77,7 @@ export async function getAlertsMapFromPurls(
7977
return alertsByPurl
8078
}
8179

80+
const { spinner } = opts
8281
const getText = () => `Looking up data for ${remaining} packages`
8382

8483
spinner?.start(getText())
@@ -91,20 +90,20 @@ export async function getAlertsMapFromPurls(
9190
const sockSdk = sockSdkCResult.data
9291

9392
const alertsMapOptions = {
94-
overrides: options.overrides,
95-
consolidate: options.consolidate,
96-
include: options.include,
93+
overrides: opts.overrides,
94+
consolidate: opts.consolidate,
95+
include: opts.include,
9796
spinner,
9897
}
9998

10099
for await (const batchResult of sockSdk.batchPackageStream(
101100
{
102101
alerts: 'true',
103102
compact: 'true',
104-
...(options.include.actions
105-
? { actions: options.include.actions.join(',') }
103+
...(opts.include.actions
104+
? { actions: opts.include.actions.join(',') }
106105
: {}),
107-
...(options.include.unfixable ? {} : { fixable: 'true' }),
106+
...(opts.include.unfixable ? {} : { fixable: 'true' }),
108107
},
109108
{
110109
components: uniqPurls.map(purl => ({ purl })),
@@ -116,7 +115,7 @@ export async function getAlertsMapFromPurls(
116115
alertsByPurl,
117116
alertsMapOptions,
118117
)
119-
} else if (!options.nothrow) {
118+
} else if (!opts.nothrow) {
120119
const statusCode = batchResult.status ?? 'unknown'
121120
const statusMessage = batchResult.error ?? 'No status message'
122121
throw new Error(

0 commit comments

Comments
 (0)