Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhd124/79e77be391a1b9aaafb30bab03b89bb3 to your computer and use it in GitHub Desktop.
Save jhd124/79e77be391a1b9aaafb30bab03b89bb3 to your computer and use it in GitHub Desktop.
module.exports = function ({ parse }){
return {
visitor: {
FunctionDeclaration(path){
const node = path.node;
const functionName = node.id.name;
const consoleLogNode = parse(`console.log(${functionName})`);
path.get("body").unshiftContainer("body", consoleLogNode.program.body[0]);
},
},
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment