mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-23 09:31:52 -04:00
fix: pnpm i should work on virtual drives (#4386)
This is reproducible on Windows with virtual drives created by subst command
This commit is contained in:
5
.changeset/itchy-pigs-deny.md
Normal file
5
.changeset/itchy-pigs-deny.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
---
|
||||
|
||||
pnpm i should work correctly on virtual drives instead of silently shutting down
|
||||
@@ -54,7 +54,8 @@
|
||||
"tempy": "^1.0.0",
|
||||
"write-json-file": "^4.3.0",
|
||||
"write-pkg": "4.0.0",
|
||||
"write-yaml-file": "^4.2.0"
|
||||
"write-yaml-file": "^4.2.0",
|
||||
"symlink-dir": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/cli-utils": "workspace:0.6.49",
|
||||
|
||||
@@ -176,7 +176,7 @@ export default async function recursive (
|
||||
// For a workspace with shared lockfile
|
||||
if (opts.lockfileDir && ['add', 'install', 'remove', 'update', 'import'].includes(cmdFullName)) {
|
||||
let importers = await getImporters()
|
||||
const calculatedRepositoryRoot = calculateRepositoryRoot(opts.workspaceDir, importers.map(x => x.rootDir))
|
||||
const calculatedRepositoryRoot = await fs.realpath(calculateRepositoryRoot(opts.workspaceDir, importers.map(x => x.rootDir)))
|
||||
const isFromWorkspace = isSubdir.bind(null, calculatedRepositoryRoot)
|
||||
importers = await pFilter(importers, async ({ rootDir }: { rootDir: string }) => isFromWorkspace(await fs.realpath(rootDir)))
|
||||
if (importers.length === 0) return true
|
||||
|
||||
@@ -12,6 +12,7 @@ import loadJsonFile from 'load-json-file'
|
||||
import writeJsonFile from 'write-json-file'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
import { DEFAULT_OPTS } from './utils'
|
||||
import symlinkDir from 'symlink-dir'
|
||||
|
||||
test('recursive add/remove', async () => {
|
||||
const projects = preparePackages([
|
||||
@@ -643,3 +644,30 @@ test('prefer-workspace-package', async () => {
|
||||
const lockfile = await readYamlFile<Lockfile>(path.resolve('pnpm-lock.yaml'))
|
||||
expect(lockfile.importers['project-1'].dependencies?.foo).toBe('link:../foo')
|
||||
})
|
||||
|
||||
test('installing in monorepo with shared lockfile should work on virtual drives', async () => {
|
||||
const projects = preparePackages([
|
||||
{
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
},
|
||||
])
|
||||
const virtualPath = process.cwd() + '-virtual-disk'
|
||||
// symlink simulates windows' subst
|
||||
await symlinkDir(process.cwd(), virtualPath)
|
||||
const { allProjects, selectedProjectsGraph } = await readProjects(virtualPath, [])
|
||||
await install.handler({
|
||||
...DEFAULT_OPTS,
|
||||
lockfileDir: virtualPath,
|
||||
allProjects,
|
||||
dir: virtualPath,
|
||||
recursive: true,
|
||||
selectedProjectsGraph,
|
||||
workspaceDir: virtualPath,
|
||||
})
|
||||
|
||||
await projects['project-1'].has('is-positive')
|
||||
})
|
||||
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -2154,6 +2154,7 @@ importers:
|
||||
read-yaml-file: ^2.1.0
|
||||
render-help: ^1.0.1
|
||||
sinon: ^11.1.1
|
||||
symlink-dir: ^5.0.0
|
||||
tempy: ^1.0.0
|
||||
version-selector-type: ^3.0.0
|
||||
write-json-file: ^4.3.0
|
||||
@@ -2225,6 +2226,7 @@ importers:
|
||||
proxyquire: 2.1.3
|
||||
read-yaml-file: 2.1.0
|
||||
sinon: 11.1.2
|
||||
symlink-dir: 5.0.1
|
||||
tempy: 1.0.1
|
||||
write-json-file: 4.3.0
|
||||
write-pkg: 4.0.0
|
||||
|
||||
Reference in New Issue
Block a user