简体   繁体   English

gulp 4.0 allowEmpty: true 不适用于空数组

[英]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错误:无效的 glob 参数:为上述代码段抛出

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?无论如何将allowEmpty用于空数组?

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.无论如何,可以通过跳过空数组的任务来解决这个问题,只是想知道是否有任何正确的方法可以将 allowEmpty 用于空数组。

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. src()的第一个参数需要一个字符串或一个字符串数组,而不是一个空数组。 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. allowEmpty选项只是抑制在未找到匹配项时引发的错误——它不会更改可以在第一个参数中传递的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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