Jade isn't called "Jade" any more. It is now known as "Pug". In order to convert an old jade project into the new pug format, you need to rename all the old .jade files to .pug files.
Doing it by hand is painful and tedious, surely there is a faster way to do it?
Jade isn't called "Jade" any more. It is now known as "Pug". In order to convert an old jade project into the new pug format, you need to rename all the old .
Due to a trademark issue, the project name has been changed from “Jade” to “Pug” in conjunction with the release of Pug 2. This also means that we have changed the official supported file extension from . jade to .
On Windows, you can rename extension recursively by this command:
for /R %x in (*.jade) do ren "%x" *.pug
Taken from this answer.
Note that this only works in Windows Command Prompt. You will receive errors if you try to run this command in programs like Git Bash or Windows PowerShell.
If you are a Mac user, use this command in Mac Terminal:
find . -name '*.jade' | xargs rename 's/\.jade$/.pug/'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With