Skip to content

Commit

Permalink
make yarn cache dir always added to allowDirs list
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoyu committed Mar 9, 2024
1 parent f652648 commit 6d076be
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,24 +989,25 @@ export function resolveServerOptions(

if (!allowDirs) {
allowDirs = [searchForWorkspaceRoot(root)]
if (process.versions.pnp) {
try {
const enableGlobalCache =
execSync('yarn config get enableGlobalCache', { cwd: root })
.toString()
.trim() === 'true'
const yarnCacheDir = execSync(
`yarn config get ${enableGlobalCache ? 'globalFolder' : 'cacheFolder'}`,
{ cwd: root },
)
}

if (process.versions.pnp) {
try {
const enableGlobalCache =
execSync('yarn config get enableGlobalCache', { cwd: root })
.toString()
.trim()
allowDirs.push(yarnCacheDir)
} catch (e) {
logger.warn(`Get yarn cache dir error: ${e.message}`, {
timestamp: true,
})
}
.trim() === 'true'
const yarnCacheDir = execSync(
`yarn config get ${enableGlobalCache ? 'globalFolder' : 'cacheFolder'}`,
{ cwd: root },
)
.toString()
.trim()
allowDirs.push(yarnCacheDir)
} catch (e) {
logger.warn(`Get yarn cache dir error: ${e.message}`, {
timestamp: true,
})
}
}

Expand Down

0 comments on commit 6d076be

Please sign in to comment.