fix: frozen install with dir deps that have no manifest (#3793)

This commit is contained in:
Zoltan Kochan
2021-09-25 00:14:42 +03:00
committed by GitHub
parent a9b4ff4fc8
commit b7e6f4428e
3 changed files with 17 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/headless": patch
---
Frozen install should not fail if the lockfile contains references to directories with no `package.json` file.

View File

@@ -488,8 +488,13 @@ async function linkRootPackages (
if (importerManifestsByImporterId[importerId]) {
return importerManifestsByImporterId[importerId]
}
// TODO: cover this case with a test
return await readProjectManifestOnly(packageDir) as DependencyManifest
try {
// TODO: cover this case with a test
return await readProjectManifestOnly(packageDir) as DependencyManifest
} catch (err) {
if (err['code'] !== 'ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND') throw err
return { name: alias, version: '0.0.0' }
}
})() as DependencyManifest
await symlinkDirectRootDependency(packageDir, opts.importerModulesDir, alias, {
fromDependenciesField: isDev && 'devDependencies' ||

View File

@@ -57,6 +57,11 @@ test('local directory with no package.json', async () => {
const expectedSpecs = { pkg: 'link:pkg' }
expect(manifest.dependencies).toStrictEqual(expectedSpecs)
await project.has('pkg')
await rimraf('node_modules')
await install(manifest, await testDefaults({ frozenLockfile: true }))
await project.has('pkg')
})
test('local file via link:', async () => {