I made this Gulp task to convert all the files for me in one hit :)
It requires the gulp-rename and del npm plugins to work.
Use this if all the jade files are within the root gulp folder (ie. the folder that the main gulp file is in)
//Use this if all jade files are inside gulps root folder
var rename = require("gulp-rename");
var del = require('del');
gulp.task('switch-to-pug', function() {
console.log('\nCreated:\n');
gulp.src(['**/*.jade'])
.pipe(rename(function(path){
path.extname = ".pug";
console.log(path.dirname+'/'+path.basename + path.extname+'\n');
}))
.pipe(gulp.dest('./'))
.on('end', function(){
del(['**/*.jade']).then(function(paths){
console.log('\nDeleted:\n\n', paths.join('\n'));
});
});
});
Use this (and edit the paths to suit your needs) if there are files outside the root gulp folder that you also want to rename:
//Use this (and edit accordingly) if jade files are also found outside the root folder
var rename = require("gulp-rename");
var del = require('del');
gulp.task('switch-to-pug', function() {
console.log('\nCreated:\n');
gulp.src(['../**/*.jade'])
.pipe(rename(function(path){
path.extname = ".pug";
console.log(path.dirname+'/'+path.basename + path.extname+'\n');
}))
.pipe(gulp.dest('../'))
.on('end', function(){
del(['../**/*.jade'], { force: true }).then(function(paths){
console.log('\nDeleted:\n\n', paths.join('\n'));
});
});
});
Then just run this and it will change all the files for you :)
gulp switch-to-pug
rename
is not a standard unix command, and is not available on a mac. Not a big issue, however, abrew install rename
can solve the problem :) – Conscript