From 0fb1d7ddafac92dd0df8de3ce2626c4fa485d438 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 18 Aug 2021 23:32:36 +0300 Subject: [PATCH] fix(config): default home directory on macOS ref #2574 --- .changeset/cyan-clouds-care.md | 5 +++++ packages/config/src/dirs.ts | 5 ++++- packages/config/test/dirs.test.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/cyan-clouds-care.md diff --git a/.changeset/cyan-clouds-care.md b/.changeset/cyan-clouds-care.md new file mode 100644 index 00000000000..806bba72c92 --- /dev/null +++ b/.changeset/cyan-clouds-care.md @@ -0,0 +1,5 @@ +--- +"@pnpm/config": patch +--- + +The default home directory for pnpm on macOS should be at `~/Library/pnpm`. diff --git a/packages/config/src/dirs.ts b/packages/config/src/dirs.ts index b282f1c4222..a3f0668b445 100644 --- a/packages/config/src/dirs.ts +++ b/packages/config/src/dirs.ts @@ -49,7 +49,10 @@ export function getDataDir ( if (opts.env.XDG_DATA_HOME) { return path.join(opts.env.XDG_DATA_HOME, 'pnpm') } - if (opts.platform !== 'win32' && opts.platform !== 'darwin') { + if (opts.platform === 'darwin') { + return path.join(os.homedir(), 'Library/pnpm') + } + if (opts.platform !== 'win32') { return path.join(os.homedir(), '.local/share/pnpm') } if (opts.env.LOCALAPPDATA) { diff --git a/packages/config/test/dirs.test.ts b/packages/config/test/dirs.test.ts index 1b623abad41..ad9d5934b4a 100644 --- a/packages/config/test/dirs.test.ts +++ b/packages/config/test/dirs.test.ts @@ -70,7 +70,7 @@ test('getDataDir()', () => { expect(getDataDir({ env: {}, platform: 'darwin', - })).toBe(path.join(os.homedir(), '.pnpm')) + })).toBe(path.join(os.homedir(), 'Library/pnpm')) expect(getDataDir({ env: { LOCALAPPDATA: '/localappdata',