Skip to content

fix: get cache dir for custom path#20

Merged
fengmk2 merged 2 commits intovoidzero-dev:mainfrom
hyoban:4-23-cache-path
Mar 23, 2026
Merged

fix: get cache dir for custom path#20
fengmk2 merged 2 commits intovoidzero-dev:mainfrom
hyoban:4-23-cache-path

Conversation

@hyoban
Copy link
Copy Markdown
Contributor

@hyoban hyoban commented Mar 23, 2026

Tested in langgenius/dify#33950, it works fine.

Copilot AI review requested due to automatic review settings March 23, 2026 13:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates dependency-cache resolution so that when a lockfile is provided via cache-dependency-path (including subdirectory paths), the action resolves the package-manager cache directory relative to the lockfile’s directory rather than always using the workspace root.

Changes:

  • Add getCacheDirectoryCwd() to derive an appropriate working directory from the lockfile path.
  • Pass cwd through to the vp pm cache dir invocation so cache location is resolved in the intended project directory.
  • Improve cache-restore warning messages and add unit tests for the new behavior; document the behavior in the README.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/utils.ts Introduces getCacheDirectoryCwd() and threads cwd into cache-dir resolution (vp pm cache dir).
src/cache-restore.ts Uses lockfile-derived cwd and improves warning messages when lockfile/cache dirs are missing.
src/utils.test.ts Adds mocks and tests for getCacheDirectoryCwd() and getCacheDirectories() cwd behavior.
README.md Documents cache resolution behavior when cache-dependency-path points into a subdirectory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cache-restore.ts
Comment on lines 21 to +26
info(`Using lock file: ${lockFile.path}`);
const cacheCwd = getCacheDirectoryCwd(lockFile.path);
info(`Resolving dependency cache directory in: ${cacheCwd}`);

// Get cache directories based on lock file type
const cachePaths = await getCacheDirectories(lockFile.type);
const cachePaths = await getCacheDirectories(lockFile.type, cacheCwd);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI enforces that compiled dist/ artifacts are committed and up-to-date after source changes (see .github/workflows/test.yml step “Verify dist is up to date”). This PR updates src/ behavior, so make sure to run vp run build and include any resulting dist/ changes in the PR to avoid CI failures.

Copilot uses AI. Check for mistakes.
@fengmk2 fengmk2 merged commit 906b582 into voidzero-dev:main Mar 23, 2026
34 of 35 checks passed
@fengmk2
Copy link
Copy Markdown
Member

fengmk2 commented Mar 23, 2026

@hyoban Thanks!

fengmk2 pushed a commit that referenced this pull request Mar 23, 2026
Follow #20

I found that the version printed by vite+ is also incorrect. I'm
thinking that adding a `working-directory` might be better, which could
also simplify the configuration.

It looks like the `working-directory` from the GitHub action does not
work with `uses`. https://github.com/orgs/community/discussions/25742

Feel free to close this PR if you do not want to introduce another "cwd"
input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants