@@ -14,6 +14,7 @@ import {
1414 resolvePackageName ,
1515} from '@socketsecurity/registry/lib/packages'
1616import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
17+ import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
1718
1819import { getActiveBranchesForPackage } from './fix-branch-helpers.mts'
1920import { getActualTree } from './get-actual-tree.mts'
@@ -47,7 +48,7 @@ import { getPurlObject } from '../../utils/purl.mts'
4748import { applyRange } from '../../utils/semver.mts'
4849import { getCveInfoFromAlertsMap } from '../../utils/socket-package-alert.mts'
4950import { idToPurl } from '../../utils/spec.mts'
50- import { overridesDataByAgent } from '../optimize/get-overrides-by-agent.mts'
51+ import { getOverridesData } from '../optimize/get-overrides-by-agent.mts'
5152
5253import type { CiEnv } from './fix-env-helpers.mts'
5354import type { PrMatch } from './open-pr.mts'
@@ -146,8 +147,6 @@ export async function agentFix(
146147 ( a , b ) => naturalCompare ( a [ 0 ] , b [ 0 ] ) ,
147148 )
148149
149- const getOverridesData = overridesDataByAgent . get ( pkgEnvDetails . agent ) !
150-
151150 const cleanupInfoEntriesLoop = ( ) => {
152151 logger . dedent ( )
153152 spinner ?. dedent ( )
@@ -324,18 +323,17 @@ export async function agentFix(
324323 continue infosLoop
325324 }
326325
327- const oldOverrides = getOverridesData (
326+ const { overrides : oldOverrides } = getOverridesData (
328327 pkgEnvDetails ,
329328 editablePkgJson . content ,
330329 )
331- const overrideKey = `${ name } @${ vulnerableVersionRange } `
332-
333- const newVersionRange = applyRange (
334- ( oldOverrides as any ) ?. [ overrideKey ] ?? oldVersion ,
335- newVersion ,
336- rangeStyle ,
337- )
338- const newId = `${ name } @${ newVersionRange } `
330+ let refRange = oldOverrides ?. [ `${ name } @${ vulnerableVersionRange } ` ]
331+ if ( ! isNonEmptyString ( refRange ) ) {
332+ refRange = oldOverrides ?. [ name ]
333+ }
334+ if ( ! isNonEmptyString ( refRange ) ) {
335+ refRange = oldVersion
336+ }
339337
340338 // eslint-disable-next-line no-await-in-loop
341339 await beforeInstall (
@@ -346,7 +344,6 @@ export async function agentFix(
346344 vulnerableVersionRange ,
347345 options ,
348346 )
349-
350347 updatePackageJsonFromNode (
351348 editablePkgJson ,
352349 actualTree ,
@@ -370,6 +367,8 @@ export async function agentFix(
370367 workspaceLogCallCount = logger . logCallCount
371368 }
372369
370+ const newId = `${ name } @${ applyRange ( refRange , newVersion , rangeStyle ) } `
371+
373372 spinner ?. start ( )
374373 spinner ?. info ( `Installing ${ newId } in ${ workspace } .` )
375374
0 commit comments