diff --git a/builder/policy/policy.spec.ts b/builder/policy/policy.spec.ts index 019f0a0..19239f6 100644 --- a/builder/policy/policy.spec.ts +++ b/builder/policy/policy.spec.ts @@ -52,3 +52,9 @@ it('should onlyBuiltDependencies set via a file and config', () => { it('should return undefined if no policy is set', () => { expect(createAllowBuildFunction({})).toBeUndefined() }) + +it('should return undefined if onlyBuiltDependencies is empty array', () => { + expect(createAllowBuildFunction({ + onlyBuiltDependencies: [], + })).toBeUndefined() +}) diff --git a/builder/policy/policy.ts b/builder/policy/policy.ts index 06a362e..c5d815d 100644 --- a/builder/policy/policy.ts +++ b/builder/policy/policy.ts @@ -7,7 +7,7 @@ export function createAllowBuildFunction ( onlyBuiltDependenciesFile?: string } ): undefined | ((pkgName: string) => boolean) { - if (opts.onlyBuiltDependenciesFile || opts.onlyBuiltDependencies != null) { + if (opts.onlyBuiltDependenciesFile || opts.onlyBuiltDependencies?.length) { const onlyBuiltDeps = opts.onlyBuiltDependencies ?? [] if (opts.onlyBuiltDependenciesFile) { onlyBuiltDeps.push(...JSON.parse(fs.readFileSync(opts.onlyBuiltDependenciesFile, 'utf8')))