Skip to content

Allow append/prepend API for function bodies / Expose nodes modules #24

@Exagram

Description

@Exagram

Are we able to get append/prepend API for inserting calls in function bodies? Currently the append/prepend API only works for the tree body.

Example:

function test() {
    foo('test');
}

Fails: c.body.node[0].body.append('bar();').

So I looked for workarounds. I tried to manually push this new call into the body array via c.body.node[0].body.body.push('bar();'). But doing so fails because bar(); is a string and not an esprima object. A possible solution is to expose AST-query nodes modules so we can do the above. Or add documentation that the body array requires an esprima object.

I can code this change, just need vision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions