Skip to content

Commit

Permalink
feat: shrink path to the global directory (to reduce chance of too lo…
Browse files Browse the repository at this point in the history
…ng names on Windows) (#4591)
  • Loading branch information
zkochan committed Apr 19, 2022
1 parent c16eb2b commit 066f38d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default async (
if (pnpmConfig['globalDir']) {
globalDirRoot = pnpmConfig['globalDir']
} else {
globalDirRoot = path.join(pnpmConfig.pnpmHomeDir, 'global-packages')
globalDirRoot = path.join(pnpmConfig.pnpmHomeDir, 'global')
}
pnpmConfig.dir = path.join(globalDirRoot, LAYOUT_VERSION.toString())

Expand Down Expand Up @@ -317,7 +317,7 @@ export default async (
throw new PnpmError('CONFIG_CONFLICT_VIRTUAL_STORE_DIR_WITH_GLOBAL',
'Configuration conflict. "virtual-store-dir" may not be used with "global"')
}
delete pnpmConfig.virtualStoreDir
pnpmConfig.virtualStoreDir = '.pnpm'
} else {
pnpmConfig.dir = cwd
pnpmConfig.bin = path.join(pnpmConfig.dir, 'node_modules', '.bin')
Expand Down
6 changes: 3 additions & 3 deletions packages/pnpm/test/install/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('global installation', async () => {
// https://github.com/pnpm/pnpm/issues/808
await execPnpm(['install', '--global', 'is-negative'], { env })

const globalPrefix = path.join(global, `pnpm/global-packages/${LAYOUT_VERSION}`)
const globalPrefix = path.join(global, `pnpm/global/${LAYOUT_VERSION}`)

const { default: isPositive } = await import(path.join(globalPrefix, 'node_modules', 'is-positive'))
expect(typeof isPositive).toBe('function')
Expand Down Expand Up @@ -58,7 +58,7 @@ test('always install latest when doing global installation without spec', async
await execPnpm(['install', '-g', 'peer-c@1'], { env })
await execPnpm(['install', '-g', 'peer-c'], { env })

const globalPrefix = path.join(global, `pnpm/global-packages/${LAYOUT_VERSION}`)
const globalPrefix = path.join(global, `pnpm/global/${LAYOUT_VERSION}`)

process.chdir(globalPrefix)

Expand All @@ -85,5 +85,5 @@ test('run lifecycle events of global packages in correct working directory', asy

await execPnpm(['install', '-g', 'postinstall-calls-pnpm@1.0.0'], { env })

expect(await exists(path.join(global, `pnpm/global-packages/${LAYOUT_VERSION}/node_modules/postinstall-calls-pnpm/created-by-postinstall`))).toBeTruthy()
expect(await exists(path.join(global, `pnpm/global/${LAYOUT_VERSION}/node_modules/postinstall-calls-pnpm/created-by-postinstall`))).toBeTruthy()
})
2 changes: 1 addition & 1 deletion packages/pnpm/test/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ test('pnpm root -g', async () => {
const result = execPnpmSync(['root', '-g'], { env })

expect(result.status).toBe(0)
expect(result.stdout.toString()).toBe(path.join(global, `pnpm/global-packages/${LAYOUT_VERSION}/node_modules`) + '\n')
expect(result.stdout.toString()).toBe(path.join(global, `pnpm/global/${LAYOUT_VERSION}/node_modules`) + '\n')
})

0 comments on commit 066f38d

Please sign in to comment.