mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-22 21:53:02 -04:00
fix: git dependencies respect dangerouslyAllowAllBuilds (#10387)
close #10376
This commit is contained in:
6
.changeset/early-numbers-look.md
Normal file
6
.changeset/early-numbers-look.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/builder.policy": minor
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Git dependencies with build scripts should respect the `dangerouslyAllowAllBuilds` settings [#10376](https://github.com/pnpm/pnpm/issues/10376).
|
||||
@@ -4,11 +4,13 @@ import fs from 'fs'
|
||||
|
||||
export function createAllowBuildFunction (
|
||||
opts: {
|
||||
dangerouslyAllowAllBuilds?: boolean
|
||||
neverBuiltDependencies?: string[]
|
||||
onlyBuiltDependencies?: string[]
|
||||
onlyBuiltDependenciesFile?: string
|
||||
}
|
||||
): undefined | AllowBuild {
|
||||
if (opts.dangerouslyAllowAllBuilds) return () => true
|
||||
if (opts.onlyBuiltDependenciesFile != null || opts.onlyBuiltDependencies != null) {
|
||||
const onlyBuiltDeps = opts.onlyBuiltDependencies ?? []
|
||||
if (opts.onlyBuiltDependenciesFile) {
|
||||
|
||||
@@ -55,3 +55,11 @@ it('should onlyBuiltDependencies set via a file and config', () => {
|
||||
it('should return undefined if no policy is set', () => {
|
||||
expect(createAllowBuildFunction({})).toBeUndefined()
|
||||
})
|
||||
|
||||
it('should allow everything when dangerouslyAllowAllBuilds is true', () => {
|
||||
const allowBuild = createAllowBuildFunction({
|
||||
dangerouslyAllowAllBuilds: true,
|
||||
})
|
||||
expect(typeof allowBuild).toBe('function')
|
||||
expect(allowBuild!('foo', '1.0.0')).toBeTruthy()
|
||||
})
|
||||
|
||||
@@ -299,3 +299,14 @@ test('the list of ignored builds is preserved after a repeat install', async ()
|
||||
'esbuild@0.25.0',
|
||||
])
|
||||
})
|
||||
|
||||
test('git dependencies with preparation scripts should be installed when dangerouslyAllowAllBuilds is true', async () => {
|
||||
prepare({})
|
||||
await writeYamlFile('pnpm-workspace.yaml', { dangerouslyAllowAllBuilds: true })
|
||||
|
||||
// 'test-git-fetch' has a prepare script that builds the package.
|
||||
const result = execPnpmSync(['add', 'https://github.com/pnpm/test-git-fetch.git#8b333f12d5357f4f25a654c305c826294cb073bf'])
|
||||
|
||||
expect(result.status).toBe(0)
|
||||
expect(fs.existsSync('node_modules/test-git-fetch/dist/index.js')).toBeTruthy()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user