Created
March 13, 2012 23:56
-
-
Save nemtsov/2032783 to your computer and use it in GitHub Desktop.
Simple command-line util for beautifying js files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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