Curly braces in glob without commas do not work
When curly braces ({}
) are used in a glob, it does not work fine in case it contains no commas.
Here you have a testing example:
const { src, dest } = require('gulp'),
extensions = ['css', 'js'];
exports.default = function () {
return src(`src/**/*.{${extensions.join()}}`)
.pipe(dest('dest/'));
};
It works good like this.
The point is that the trouble appears as soon as the array has only one item. To resolve it, it is necessary to add a trailing comma:
const { src, dest } = require('gulp'),
- extensions = ['css', 'js'];
+ extensions = ['css'];
exports.default = function () {
- return src(`src/**/*.{${extensions.join()}}`)
+ return src(`src/**/*.{${extensions.join()},}`)
.pipe(dest('dest/'));
};
Why, with a list of options, some comma is always required? Is it right? Is this an expected feature? And Gulp cannot avoid it from usual operation of Bash, globbing patterns...? I did not found any documentation that explains this.