I have a gulp task which can take parameters, specifically the parameter "--only {filename.ext}".
The problem is, if it's e.g. --only fOObaR.jade
it also matches the file called foobar.jade
, which is okay.
But then it passes the fOObaR
through the pipe instead of the matched (and right) foobar
, resulting in an HTML file also called fOObaR.html
.
Is there any way I can get the filename of the match, instead of the filename which I pass through gulp.src()
?
I already tried gulp-tap
with no luck.
I'm thinking of something like:
- Get all files from the source directory beforehand
- Filter those out that don't match a certain criteria
- Start the task
- Start gulp-tap
- Go through all files we already got beforehand
- If the given file matches one of those, return file from the list to get the correct filename
Trying to get this to work now. If someone has useful tips or a better way to do this, let me know! =)
Here is my task, simplified (and hopefully helpful):
var gulp = require('gulp');
var jade = require('gulp-jade');
var args = require('yargs').argv;
gulp.task('html', function () {
var source = [];
var sourceGlob = '*.jade';
var only = args.only || '';
if (only.indexOf('.jade') > -1) {
sourceGlob = only;
}
source.push(paths.src.views + '/**/' + sourceGlob);
return gulp.src(source)
.pipe(jade({ pretty: true }))
.pipe(gulp.dest(paths.dest.views));
});