esprima 与 escodegen 格式化代码(带注释)
var jsContentStr1 = fs.readFileSync(path.join(__dirname,"output","newGenEpos.js"),"utf-8"); let jsBodyArr1 = esprima.parseScript(jsContentStr1,{ range: true, tokens: true, comment: true }).body; let tree = esprima.parseScript(jsContentStr1,{ range: true, tokens: true, comment: true }); tree = escodegen.attachComments(tree, tree.comments, tree.tokens); escodegen.generate(tree.body[0],{comment:true})