Skip to content

Commit

Permalink
yarn-classic: verify repo when resolving project
Browse files Browse the repository at this point in the history
Verify the yarn project is not a PnP (Plug'n'play) install before
resolving the project

Signed-off-by: Taylor Madore <[email protected]>
  • Loading branch information
taylormadore committed Nov 19, 2024
1 parent 96534da commit 6e30b72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions cachi2/core/package_managers/yarn_classic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _resolve_yarn_project(project: Project, output_dir: RootedPath) -> None:
"""Process a request for a single yarn source directory."""
log.info(f"Fetching the yarn dependencies at the subpath {project.source_dir}")

_verify_repository(project)
prefetch_env = _get_prefetch_environment_variables(output_dir)
_verify_corepack_yarn_version(project.source_dir, prefetch_env)
_fetch_dependencies(project.source_dir, prefetch_env)
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/package_managers/yarn_classic/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def test_fetch_yarn_source(
@mock.patch("cachi2.core.package_managers.yarn_classic.main._verify_corepack_yarn_version")
@mock.patch("cachi2.core.package_managers.yarn_classic.main._get_prefetch_environment_variables")
@mock.patch("cachi2.core.package_managers.yarn_classic.main._fetch_dependencies")
@mock.patch("cachi2.core.package_managers.yarn_classic.main._verify_repository")
def test_resolve_yarn_project(
mock_verify_repository: mock.Mock,
mock_fetch_dependencies: mock.Mock,
mock_prefetch_env_vars: mock.Mock,
mock_verify_yarn_version: mock.Mock,
Expand All @@ -106,6 +108,7 @@ def test_resolve_yarn_project(

_resolve_yarn_project(project, output_dir)

mock_verify_repository.assert_called_once_with(project)
mock_prefetch_env_vars.assert_called_once_with(output_dir)
mock_verify_yarn_version.assert_called_once_with(
project.source_dir, mock_prefetch_env_vars.return_value
Expand Down

0 comments on commit 6e30b72

Please sign in to comment.