Skip to content

Commit 92a5242

Browse files
committed
pnpm: Rename _strip_peer_suffix function
The suffix may contain also a patch hash. Rename the function to a more suitable name and add one more doctest. Signed-off-by: Michal Šoltis <msoltis@redhat.com>
1 parent e07f5b0 commit 92a5242

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • hermeto/core/package_managers/javascript/pnpm

hermeto/core/package_managers/javascript/pnpm/resolver.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,20 @@ def _find_non_dev_dependencies(lockfile: PnpmLock) -> set[str]:
177177
# the «packages» section of the lockfile. See:
178178
# https://github.com/argoproj/argo-cd/blob/bf1591de63e39b7c3be5f5ba54abe8763de1a48c/ui/pnpm-lock.yaml#L2164
179179
# https://github.com/argoproj/argo-cd/blob/bf1591de63e39b7c3be5f5ba54abe8763de1a48c/ui/pnpm-lock.yaml#L7869
180-
return {_strip_peer_suffix(id) for id in seen}
180+
return {_strip_dependency_path_suffix(id) for id in seen}
181181

182182

183-
def _strip_peer_suffix(package_id: str) -> str:
183+
def _strip_dependency_path_suffix(package_id: str) -> str:
184184
"""
185-
>>> _strip_peer_suffix('pkg@1.0.0')
185+
https://github.com/pnpm/pnpm/blob/46fd26afc9926b4391636a851ae32493f9b2c9ff/deps/path/src/index.ts#L52
186+
187+
>>> _strip_dependency_path_suffix('pkg@1.0.0')
188+
'pkg@1.0.0'
189+
>>> _strip_dependency_path_suffix('pkg@1.0.0(foo@2.0.0)')
186190
'pkg@1.0.0'
187-
>>> _strip_peer_suffix('pkg@1.0.0(foo@2.0.0)')
191+
>>> _strip_dependency_path_suffix('pkg@1.0.0(foo@2.0.0)(bar@2.0.0)')
188192
'pkg@1.0.0'
189-
>>> _strip_peer_suffix('pkg@1.0.0(foo@2.0.0)(bar@2.0.0)')
193+
>>> _strip_dependency_path_suffix('pkg@1.0.0(patch_hash=abc123)')
190194
'pkg@1.0.0'
191195
"""
192196
return package_id.partition("(")[0]

0 commit comments

Comments
 (0)