Skip to content

Instantly share code, notes, and snippets.

@dunkfordyce
Created November 13, 2012 11:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dunkfordyce/4065345 to your computer and use it in GitHub Desktop.
Save dunkfordyce/4065345 to your computer and use it in GitHub Desktop.
Convert single line comments in javascript to console.log statements with esprima/falafel/javascript
var falafel = require('falafel');
var src = require('fs').readFileSync(process.argv[2]).toString();
var output = falafel(src, {comment: true}, function (node) {
if (node.type === 'Line') {
node.update('console.log("COMMENT:' + node.value + '");');
}
});
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment