mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 07:38:12 -05:00
fix: use proper default value for store-dir, cache-dir on macOS
ref #2574
This commit is contained in:
5
.changeset/plenty-moose-tie.md
Normal file
5
.changeset/plenty-moose-tie.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/config": patch
|
||||
---
|
||||
|
||||
Choose proper default state-dir and cache-dir on macOS.
|
||||
@@ -10,6 +10,9 @@ export function getCacheDir (
|
||||
if (opts.env.XDG_CACHE_HOME) {
|
||||
return path.join(opts.env.XDG_CACHE_HOME, 'pnpm')
|
||||
}
|
||||
if (opts.platform === 'darwin') {
|
||||
return path.join(os.homedir(), 'Library/Caches/pnpm')
|
||||
}
|
||||
if (opts.platform !== 'win32') {
|
||||
return path.join(os.homedir(), '.cache/pnpm')
|
||||
}
|
||||
@@ -28,7 +31,7 @@ export function getStateDir (
|
||||
if (opts.env.XDG_STATE_HOME) {
|
||||
return path.join(opts.env.XDG_STATE_HOME, 'pnpm')
|
||||
}
|
||||
if (opts.platform !== 'win32') {
|
||||
if (opts.platform !== 'win32' && opts.platform !== 'darwin') {
|
||||
return path.join(os.homedir(), '.local/state/pnpm')
|
||||
}
|
||||
if (opts.env.LOCALAPPDATA) {
|
||||
|
||||
@@ -13,6 +13,10 @@ test('getCacheDir()', () => {
|
||||
env: {},
|
||||
platform: 'linux',
|
||||
})).toBe(path.join(os.homedir(), '.cache/pnpm'))
|
||||
expect(getCacheDir({
|
||||
env: {},
|
||||
platform: 'darwin',
|
||||
})).toBe(path.join(os.homedir(), 'Library/Caches/pnpm'))
|
||||
expect(getCacheDir({
|
||||
env: {
|
||||
LOCALAPPDATA: '/localappdata',
|
||||
@@ -36,6 +40,10 @@ test('getStateDir()', () => {
|
||||
env: {},
|
||||
platform: 'linux',
|
||||
})).toBe(path.join(os.homedir(), '.local/state/pnpm'))
|
||||
expect(getStateDir({
|
||||
env: {},
|
||||
platform: 'darwin',
|
||||
})).toBe(path.join(os.homedir(), '.pnpm-state'))
|
||||
expect(getStateDir({
|
||||
env: {
|
||||
LOCALAPPDATA: '/localappdata',
|
||||
|
||||
Reference in New Issue
Block a user