fix: onlyBuiltDependencies (#8921)

close #8920
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2024-12-29 02:18:01 +01:00
1 parent f89128883f
commit f90a94b474
3 files changed
+20 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@pnpm/config": patch
---
Fix reading options from pnpm.onlyBuiltDependencies [#8920](https://github.com/pnpm/pnpm/issues/8920).
@@ -37,7 +37,7 @@ export function getOptionsFromRootManifest (manifestDir: string, manifest: Proje
const neverBuiltDependencies = manifest.pnpm?.neverBuiltDependencies
let onlyBuiltDependencies = manifest.pnpm?.onlyBuiltDependencies
const onlyBuiltDependenciesFile = manifest.pnpm?.onlyBuiltDependenciesFile
if (onlyBuiltDependenciesFile == null && neverBuiltDependencies == null) {
if (onlyBuiltDependenciesFile == null && neverBuiltDependencies == null && onlyBuiltDependencies == null) {
onlyBuiltDependencies = []
}
const packageExtensions = manifest.pnpm?.packageExtensions
@@ -77,3 +77,17 @@ test('getOptionsFromRootManifest() throws an error if cannot resolve an override
},
})).toThrow('Cannot resolve version $foo in overrides. The direct dependencies don\'t have dependency "foo".')
})
test('getOptionsFromRootManifest() should return an empty onlyBuiltDependencies list by default', () => {
const options = getOptionsFromRootManifest(process.cwd(), {})
expect(options.onlyBuiltDependencies).toStrictEqual([])
})
test('getOptionsFromRootManifest() should return the list fromm onlyBuiltDependencies', () => {
const options = getOptionsFromRootManifest(process.cwd(), {
pnpm: {
onlyBuiltDependencies: ['electron'],
},
})
expect(options.onlyBuiltDependencies).toStrictEqual(['electron'])
})