fix: get cache dir for custom path#20
Conversation
There was a problem hiding this comment.
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
cwdthrough to thevp pm cache dirinvocation 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.
| 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); |
There was a problem hiding this comment.
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.
|
@hyoban Thanks! |
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.
Tested in langgenius/dify#33950, it works fine.