import { logger } from '../../../../../logger' ; import type { YarnLock , YarnLockEntrySummary } from './types' ; export function getLockedDependencies ( yarnLock , depName , currentVersion ) { const res = [ ] ; try { for ( const [ depNameConstraint , entry ] of Object . entries ( yarnLock ) ) { let entryName ; let constraint ; const split = depNameConstraint . split ( '@' ) ; if ( split . length === 2 ) { [ entryName , constraint ] = split ; } else if ( split . length === 3 ) { entryName = '@' + split [ 1 ] ; constraint = split [ 2 ] ; } else { logger . debug ( { depNameConstraint , entry } , 'Unexpected depNameConstraint' ) ; continue ; } if ( entryName === depName && entry ?. version === currentVersion ) { res . push ( { entry , depNameConstraint , depName , constraint } ) ; } } } catch ( err ) { logger . warn ( { err } , 'getLockedDependencies() error' ) ; } return res ; }