Renaming multiple files
bretthayes opened this issue · 8 comments
bretthayes commented
Is there support for this? For example:
gulp.task('compile:jade', function() {
return gulp.src(paths.jade)
.pipe($.jade())
.pipe($.rename({
map: {
'oldFileName.html': 'newFileName.html',
'otherFile.html': 'otherFile.txt'
}
}))
.pipe(gulp.dest(paths.build));
});
yocontra commented
Use gulp-if
.pipe(gif('oldFileName.html', rename('newFileName.html'))
bretthayes commented
@contra Doesn't work. The output to my build folder still compiles the original file names. Any ideas?
gulp.task('compile:jade', function() {
return gulp.src(paths.jade)
.pipe($.jade())
.pipe($.if('oldFileName.html', $.rename('newFileName.html')))
.pipe($.if('otherFile.html', $.rename('otherFile.txt')))
.pipe(gulp.dest(paths.build));
});
shinnn commented
@bretthayes Could you show us the values of paths.jade
?
bretthayes commented
shinnn commented
gulp.task('compile:jade', function() {
return gulp.src(paths.jade)
.pipe($.jade())
.pipe($.if('**/oldFileName.html', $.rename({basename: 'newFileName'})))
.pipe($.if('**/otherFile.html', $.rename({
basename: 'otherFile',
extname: '.txt'
})))
.pipe(gulp.dest(paths.build));
});
bretthayes commented
@shinnn Perfect! Specifying the asterisks for the source made it work: **/oldfileName.html
.
Also using gulp-debug
confirmed the path ./src/jade/oldFileName.html
being output during the compilation.
Thanks guys!
shinnn commented
No problem :)