Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: onlyBuiltDependencies is an empty array #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions builder/policy/policy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
2 changes: 1 addition & 1 deletion builder/policy/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

@zkochan zkochan Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. If the array is empty it means that no dependencies are allowed to be built.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@zkochan zkochan Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all builds are ignored, then pnpm rebuild should build nothing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, pnpm rebuild will add all dependencies that do not need to execute lifecycle scripts to ignoredBuilds and write them to the .modules.yaml file, causing pnpm approve-builds to list these dependencies.

const onlyBuiltDeps = opts.onlyBuiltDependencies ?? []
if (opts.onlyBuiltDependenciesFile) {
onlyBuiltDeps.push(...JSON.parse(fs.readFileSync(opts.onlyBuiltDependenciesFile, 'utf8')))
Expand Down
Loading