Skip to content

Instantly share code, notes, and snippets.

@nemtsov
Created March 13, 2012 23:56
Show Gist options
  • Save nemtsov/2032783 to your computer and use it in GitHub Desktop.
Save nemtsov/2032783 to your computer and use it in GitHub Desktop.
Simple command-line util for beautifying js files.
// prereq: "npm install beautifyjs"
var jsb = require('beautifyjs').js_beautify,
fs = require('fs'),
fileName = process.argv[2];
if ('string' !== typeof fileName) {
console.error('Usage: node codestyle.js fileName');
return;
}
fs.readFile(fileName, function (err, data) {
if (err) {
throw err;
}
console.log(jsb(data.toString(), {
indent_size: 2,
jslint_happy: true
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment