Open kennethlynne opened 10 years ago
Yes, it's definitely useful. I'll put it in my queue, in the meanwhile any PR is welcome.
Easy enough with node-glob
:
var glob = require('glob');
// Takes a single glob, or an array of globs and returns the paths to resolved files
function (patterns, cwd) {
if (!cwd) {
cwd = process.cwd();
}
if (!Array.isArray(patterns)) {
patterns = [patterns];
}
return patterns
.map(function (pattern) {
return glob.sync(pattern);
})
.reduce(function (val, list) {
list.forEach(function (file) {
var filePath = path.relative(cwd, file);
// Make sure that files are not added multiple times (a more specific glob before a catchall)
if (val.indexOf(filePath) < 0) {
val.push(filePath);
}
});
return val;
}, []);
};
gulp.task(Tasks.INJECT, [Tasks.SASS], function () {
return gulp.src(paths.linker.input)
// Does not support urls tho
.pipe(inject(globIt(paths.sass.output + '/*.css')), 'css', {
base: paths.tmp
})
.pipe(gulp.dest(paths.linker.output));
});
I'll send a PR :)
Edit: I may send a PR :dancer:
It should be possible to define files to be injected as globs