mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-15 17:42:31 -05:00
fix: don't print patched dependencies in list of non-built deps (#8961)
close #8952
This commit is contained in:
6
.changeset/shaggy-news-tickle.md
Normal file
6
.changeset/shaggy-news-tickle.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/build-modules": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Do not print patched dependencies as ignored dependencies that require a build [#8952](https://github.com/pnpm/pnpm/issues/8952).
|
||||
@@ -57,13 +57,7 @@ export async function buildModules<T extends string> (
|
||||
}
|
||||
const chunks = buildSequence<T>(depGraph, rootDepPaths)
|
||||
const ignoredPkgs = new Set<string>()
|
||||
const allowBuild = opts.allowBuild
|
||||
? (pkgName: string) => {
|
||||
if (opts.allowBuild!(pkgName)) return true
|
||||
ignoredPkgs.add(pkgName)
|
||||
return false
|
||||
}
|
||||
: () => true
|
||||
const allowBuild = opts.allowBuild ?? (() => true)
|
||||
const groups = chunks.map((chunk) => {
|
||||
chunk = chunk.filter((depPath) => {
|
||||
const node = depGraph[depPath]
|
||||
@@ -74,10 +68,19 @@ export async function buildModules<T extends string> (
|
||||
}
|
||||
|
||||
return chunk.map((depPath) =>
|
||||
() => buildDependency(depPath, depGraph, {
|
||||
...buildDepOpts,
|
||||
ignoreScripts: Boolean(buildDepOpts.ignoreScripts) || !allowBuild(depGraph[depPath].name),
|
||||
})
|
||||
() => {
|
||||
let ignoreScripts = Boolean(buildDepOpts.ignoreScripts)
|
||||
if (!ignoreScripts) {
|
||||
if (depGraph[depPath].requiresBuild && !allowBuild(depGraph[depPath].name)) {
|
||||
ignoredPkgs.add(depGraph[depPath].name)
|
||||
ignoreScripts = true
|
||||
}
|
||||
}
|
||||
return buildDependency(depPath, depGraph, {
|
||||
...buildDepOpts,
|
||||
ignoreScripts,
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
await runGroups(opts.childConcurrency ?? 4, groups)
|
||||
|
||||
@@ -3,16 +3,19 @@ import path from 'path'
|
||||
import { type PackageFilesIndex } from '@pnpm/store.cafs'
|
||||
import { ENGINE_NAME } from '@pnpm/constants'
|
||||
import { install } from '@pnpm/core'
|
||||
import { type IgnoredScriptsLog } from '@pnpm/core-loggers'
|
||||
import { createHexHashFromFile } from '@pnpm/crypto.hash'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { fixtures } from '@pnpm/test-fixtures'
|
||||
import { sync as rimraf } from '@zkochan/rimraf'
|
||||
import loadJsonFile from 'load-json-file'
|
||||
import sinon from 'sinon'
|
||||
import { testDefaults } from '../utils'
|
||||
|
||||
const f = fixtures(__dirname)
|
||||
|
||||
test('patch package', async () => {
|
||||
const reporter = sinon.spy()
|
||||
const project = prepareEmpty()
|
||||
const patchPath = path.join(f.find('patch-pkg'), 'is-positive@1.0.0.patch')
|
||||
|
||||
@@ -20,10 +23,12 @@ test('patch package', async () => {
|
||||
'is-positive@1.0.0': patchPath,
|
||||
}
|
||||
const opts = testDefaults({
|
||||
onlyBuiltDependencies: [],
|
||||
fastUnpack: false,
|
||||
sideEffectsCacheRead: true,
|
||||
sideEffectsCacheWrite: true,
|
||||
patchedDependencies,
|
||||
reporter,
|
||||
}, {}, {}, { packageImportMethod: 'hardlink' })
|
||||
await install({
|
||||
dependencies: {
|
||||
@@ -31,6 +36,12 @@ test('patch package', async () => {
|
||||
},
|
||||
}, opts)
|
||||
|
||||
expect(reporter.calledWithMatch({
|
||||
packageNames: [],
|
||||
level: 'debug',
|
||||
name: 'pnpm:ignored-scripts',
|
||||
} as IgnoredScriptsLog)).toBeTruthy()
|
||||
|
||||
expect(fs.readFileSync('node_modules/is-positive/index.js', 'utf8')).toContain('// patched')
|
||||
|
||||
const patchFileHash = await createHexHashFromFile(patchPath)
|
||||
|
||||
Reference in New Issue
Block a user