简体   繁体   中英

gulp 4.0 allowEmpty : true is not working for empty array

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

It's expected behavior. The first parameter of src() expects either a string or an array of strings, not an empty array. The allowEmpty option just suppresses the error that is thrown if no match is found—it doesn't change what can be passed in the first parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM