Skip to content

Commit

Permalink
yarn: Expanding globs extraction to nested Arrays
Browse files Browse the repository at this point in the history
It turns out that workspaces could be either Array or
a nested Array in an Object thus we must handle both cases.
Official docs mentioning the former:
  https://classic.yarnpkg.com/lang/en/docs/workspaces/
Official blog containing a hint about the latter:
  https://classic.yarnpkg.com/lang/en/docs/workspaces/

Signed-off-by: Alexey Ovchinnikov <[email protected]>
  • Loading branch information
a-ovchinnikov committed Oct 17, 2024
1 parent f82ff5a commit ce87ae4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cachi2/core/package_managers/yarn_classic/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ def _extract_workspaces_globs(
package: dict[str, Any],
) -> list[str]:
"""Extract globs from workspaces entry in package dict."""
# This could be an Array or an Array nested in an Object.
# Official docs mentioning the former:
# https://classic.yarnpkg.com/lang/en/docs/workspaces/
# Official blog containing a hint about the latter:
# https://classic.yarnpkg.com/lang/en/docs/workspaces/
workspaces_globs = package.get("workspaces", [])
if isinstance(workspaces_globs, dict):
workspaces_globs = workspaces_globs.get("packages", [])
return workspaces_globs


Expand Down

0 comments on commit ce87ae4

Please sign in to comment.