This tiny program format a pug(former jade) template file. For reusability, it's made as a module suggested by @Glavin001. Please refer this issue.
npm install pug-beautify
npm run test
var output = pugBeautify(code);
var output = pugBeautify(code,{
fill_tab:true,
omit_div:false,
tab_size:4,
separator_space:true,
});
var fs = require('fs');
var pugBeautify = require('pug-beautify');
var code = fs.readFileSync('sample.jade','utf8');
var option = {
fill_tab: true,
omit_div: false,
tab_size: 4,
separator_space: true
};
try {
var output = pugBeautify(code,option);
}catch(error){
// Error occurred
}