@@ -14,10 +14,7 @@ import { getAlertsMapFromPurls } from '../../utils/alerts-map.mts'
1414import { getNpmConfig } from '../../utils/npm-config.mts'
1515
1616import type { FixConfig , InstallOptions } from './agent-fix.mts'
17- import type {
18- ArboristInstance ,
19- NodeClass ,
20- } from '../../shadow/npm/arborist/types.mts'
17+ import type { NodeClass } from '../../shadow/npm/arborist/types.mts'
2118import type { CResult } from '../../types.mts'
2219import type { EnvDetails } from '../../utils/package-environment.mts'
2320import type { PackageJson } from '@socketsecurity/registry/lib/packages'
@@ -49,17 +46,17 @@ export async function npmFix(
4946
5047 spinner ?. start ( )
5148
52- let arb : ArboristInstance
49+ const flatConfig = await getNpmConfig ( {
50+ npmVersion : pkgEnvDetails . agentVersion ,
51+ } )
52+
5353 let actualTree : NodeClass | undefined
5454 let alertsMap
5555 try {
5656 if ( purls . length ) {
5757 alertsMap = await getAlertsMapFromPurls ( purls , getFixAlertsMapOptions ( ) )
5858 } else {
59- const flatConfig = await getNpmConfig ( {
60- npmVersion : pkgEnvDetails . agentVersion ,
61- } )
62- arb = new Arborist ( {
59+ const arb = new Arborist ( {
6360 path : pkgEnvDetails . pkgPath ,
6461 ...flatConfig ,
6562 } )
@@ -102,6 +99,10 @@ export async function npmFix(
10299 } ) ,
103100 } as PackageJson
104101
102+ const arb = new Arborist ( {
103+ path : pkgEnvDetails . pkgPath ,
104+ ...flatConfig ,
105+ } )
105106 const idealTree = await arb . buildIdealTree ( )
106107 const node = findPackageNode ( idealTree , packument . name , oldVersion )
107108 if ( node ) {
0 commit comments