Skip to content

Instantly share code, notes, and snippets.

@stuwilli
Created December 9, 2014 15:21
Show Gist options
  • Save stuwilli/0cc81d24f128d26fc3a8 to your computer and use it in GitHub Desktop.
Save stuwilli/0cc81d24f128d26fc3a8 to your computer and use it in GitHub Desktop.
js-beautify BBEdit Text Filter
#!/usr/local/bin/node
var beautify;
try {
beautify = require("/usr/local/lib/node_modules/js-beautify").js_beautify;
} catch(e) {
console.error("js-beautify is not found");
process.exit(e.code);
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
//process.stdout.write(encodeURIComponent(chunk));
process.stdout.write(beautify(chunk, { indent_size: 4, indent_char: " " }));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment