fix: handle empty includes/excludes arrays in build config#3788
Open
JE4NVRG wants to merge 1 commit intoadaptlearning:masterfrom
Open
fix: handle empty includes/excludes arrays in build config#3788JE4NVRG wants to merge 1 commit intoadaptlearning:masterfrom
JE4NVRG wants to merge 1 commit intoadaptlearning:masterfrom
Conversation
Empty arrays are truthy in JavaScript, so checks like
`if (buildConfig.excludes)` pass even when the array has no entries.
This causes generateExcludedRegExp to produce `new RegExp('', 'i')`
which matches every file path, excluding all plugins from the build.
Add .length checks so empty arrays are treated the same as undefined.
Fixes adaptlearning#3786
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes issue #3786 where empty arrays in
build.excludesorbuild.includescause build failures.The Problem
Setting
build.excludesorbuild.includesto an empty array[]in config.json causes unexpected build failures. An empty array should be equivalent to not specifying the property at all, but instead it silently breaks plugin filtering.Root Cause
In
helpers.jsgenerateConfigData(), empty arrays pass the truthiness check and get propagated into grunt config:This produces malformed regexes that match everything, breaking the build.
The Fix
Add
.lengthchecks so empty arrays are treated identically to undefined:Testing
build.excludes: []- build now works correctlybuild.includes: []- build now works correctlyRelated Issue
Fixes #3786
Let me know if you need any changes! 🚀