mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-10 17:04:07 -04:00
feat: shrink path to the global directory (to reduce chance of too long names on Windows) (#4591)
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user