mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
fix: lockfile needs to be updated on change of neverBuiltDependencies
This commit is contained in:
5
.changeset/clean-worms-fetch.md
Normal file
5
.changeset/clean-worms-fetch.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
---
|
||||
|
||||
The lockfile needs to be updated when the value of neverBuiltDependencies changes.
|
||||
@@ -146,7 +146,11 @@ function toLockfileDependency (
|
||||
if (pkg.hasBin) {
|
||||
result['hasBin'] = true
|
||||
}
|
||||
if (opts.prevSnapshot) {
|
||||
if (pkg.requiresBuild !== undefined) {
|
||||
if (pkg.requiresBuild) {
|
||||
result['requiresBuild'] = true
|
||||
}
|
||||
} else if (opts.prevSnapshot) {
|
||||
if (opts.prevSnapshot.requiresBuild) {
|
||||
result['requiresBuild'] = opts.prevSnapshot.requiresBuild
|
||||
}
|
||||
@@ -156,10 +160,6 @@ function toLockfileDependency (
|
||||
} else if (pkg.prepare) {
|
||||
result['prepare'] = true
|
||||
result['requiresBuild'] = true
|
||||
} else if (pkg.requiresBuild !== undefined) {
|
||||
if (pkg.requiresBuild) {
|
||||
result['requiresBuild'] = true
|
||||
}
|
||||
} else {
|
||||
pendingRequiresBuilds.push(opts.depPath)
|
||||
}
|
||||
|
||||
@@ -458,3 +458,36 @@ test('selectively ignore scripts in some dependencies', async () => {
|
||||
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
|
||||
expect(await exists('node_modules/install-script-example/generated-by-install.js')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('lockfile is updated if neverBuiltDependencies is changed', async () => {
|
||||
const project = prepareEmpty()
|
||||
const manifest = await addDependenciesToPackage({},
|
||||
['pre-and-postinstall-scripts-example', 'install-script-example'],
|
||||
await testDefaults({ fastUnpack: false })
|
||||
)
|
||||
|
||||
{
|
||||
const lockfile = await project.readLockfile()
|
||||
expect(lockfile.neverBuiltDependencies).toBeFalsy()
|
||||
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBeTruthy()
|
||||
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
|
||||
}
|
||||
|
||||
const neverBuiltDependencies = ['pre-and-postinstall-scripts-example']
|
||||
manifest.pnpm = { neverBuiltDependencies }
|
||||
await mutateModules([
|
||||
{
|
||||
buildIndex: 0,
|
||||
manifest,
|
||||
mutation: 'install',
|
||||
rootDir: process.cwd(),
|
||||
},
|
||||
], await testDefaults())
|
||||
|
||||
{
|
||||
const lockfile = await project.readLockfile()
|
||||
expect(lockfile.neverBuiltDependencies).toStrictEqual(neverBuiltDependencies)
|
||||
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
|
||||
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user