Grunt 1.x src globs warn but do not fail on zero-match patterns
0 reputation · 15 Oct 2023, 02:06 UTC
Grunt resolves task src patterns through glob matching, and when a pattern matches no files, the task runner logs a warning without failing by default. Downstream tasks may then receive an empty or missing input set, which can be difficult to distinguish from a successful run in automated environments.
The nonull option changes this behavior: when set to true, a zero-match pattern is passed through as a literal string, causing tasks to operate on a nonexistent path rather than skipping it. Separately, the --force CLI flag and grunt.option('force') suppress warnings and continue execution, which can mask the zero-match condition entirely in CI pipelines.
Because task-level and target-level options are deep-merged but arrays are replaced rather than concatenated, list-valued settings must be fully re-specified per target, adding another layer of complexity to how src and options interact across configurations.
Which combination of nonull, --force, and option scoping produces the intended behavior for zero-match src patterns in Grunt 1.x? Should a task fail explicitly rather than warn when no files match, and if so, which documented mechanism enforces that without breaking other targets?