gulp 4.0 allowEmpty : true is not working for empty array

dsekswqp  于 2022-12-08  发布在  Gulp
关注(0)|答案(1)|浏览(212)
gulp.task("f1", () => {
    gulp.src([], {"allowEmpty": true})
    .pipe(gulp.dest(location));
})

Error: Invalid glob argument: is thrown for the above snippet

gulp.task("f1", () => {
    gulp.src("[]", {"allowEmpty": true})
    .pipe(gulp.dest(location));
})

whereas, it is working fine. Is this the expected behaviour ? Anyway to use allowEmpty for empty array ?
Anyhow the issue can be solved by skipping the task for empty array, just wondering is there any proper way to use allowEmpty for empty array.
Any suggestion would be helpful. Thanks in advance

wn9m85ua

wn9m85ua1#

这是预期的行为。src()的第一个参数需要一个字符串或字符串数组,而不是空数组。allowEmpty选项只是抑制在找不到匹配时抛出的错误-它不会更改第一个参数中可以传递的内容。

相关问题