Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BabelAssertionVisitor.prototype.generateCanonicalCode = function (nodePath, node) {
var file = nodePath.hub.file;
var gen = new babelgen.CodeGenerator(node, { concise: true, comments: false });
var output = gen.generate();
this.canonicalCode = output.code;
if (!this.options.embedAst) {
return;
}
var astAndTokens = this.parseCanonicalCode(file, this.canonicalCode);
this.ast = JSON.stringify(this.purifyAst(astAndTokens.expression));
this.tokens = JSON.stringify(astAndTokens.tokens);
var _this = this;
var types = this.babel.types;
this.visitorKeys = this.getOrCreateNode(nodePath, 'powerAssertVisitorKeys', function () {
return types.stringLiteral(JSON.stringify(_this.options.visitorKeys));
});
};
function generator(ast, opts, code) {
var generator = new CodeGenerator(ast, opts, code);
generator._generator.format.indent.style = ' ';
return generator.generate();
}