Skip to content

Instantly share code, notes, and snippets.

@fokusferit
Last active January 13, 2017 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fokusferit/fab904d51ef6c23f5888388743b59858 to your computer and use it in GitHub Desktop.
Save fokusferit/fab904d51ef6c23f5888388743b59858 to your computer and use it in GitHub Desktop.
Just a basic node script which saves the AST of JS code in a file.
var espree = require('espree');
var fs = require('fs');
var code = `let array = [1,2,'b'];
`;
var ast = espree.parse(code, {
ecmaVersion: 6
});
console.log("writing ast to ast.json")
fs.writeFile("ast.json", JSON.stringify(ast, null, 4), function(err) {
if(err) return err;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment