mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 23:17:08 -04:00
fix: run the install scripts of deps in a workspace with no root project (#4211)
close #4209
This commit is contained in:
5
.changeset/fresh-countries-smell.md
Normal file
5
.changeset/fresh-countries-smell.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/headless": patch
|
||||
---
|
||||
|
||||
Run the install scripts of hoisted dependencies in a workspace with no root project.
|
||||
@@ -160,3 +160,26 @@ test('run pre/postinstall scripts. bin files should be linked in a hoisted node_
|
||||
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
|
||||
expect(typeof generatedByPostinstall).toBe('function')
|
||||
})
|
||||
|
||||
// Covers https://github.com/pnpm/pnpm/issues/4209
|
||||
test('running install scripts in a workspace that has no root project', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
await mutateModules([
|
||||
{
|
||||
buildIndex: 0,
|
||||
manifest: {
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
|
||||
dependencies: {
|
||||
'pre-and-postinstall-scripts-example': '1.0.0',
|
||||
},
|
||||
},
|
||||
mutation: 'install',
|
||||
rootDir: path.resolve('project-1'),
|
||||
},
|
||||
], await testDefaults({ fastUnpack: false, nodeLinker: 'hoisted' }))
|
||||
|
||||
expect(fs.existsSync('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
|
||||
})
|
||||
|
||||
@@ -61,6 +61,7 @@ import equals from 'ramda/src/equals'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import omit from 'ramda/src/omit'
|
||||
import props from 'ramda/src/props'
|
||||
import union from 'ramda/src/union'
|
||||
import realpathMissing from 'realpath-missing'
|
||||
import linkHoistedModules from './linkHoistedModules'
|
||||
import lockfileToDepGraph, {
|
||||
@@ -385,9 +386,9 @@ export default async (opts: HeadlessOptions) => {
|
||||
)
|
||||
} else {
|
||||
const directNodes = new Set<string>()
|
||||
for (const id of importerIds) {
|
||||
for (const id of union(importerIds, ['.'])) {
|
||||
Object
|
||||
.values(directDependenciesByImporterId[id])
|
||||
.values(directDependenciesByImporterId[id] ?? {})
|
||||
.filter((loc) => graph[loc])
|
||||
.forEach((loc) => {
|
||||
directNodes.add(loc)
|
||||
|
||||
Reference in New Issue
Block a user