I've successfully used Detective in a couple of my personal projects to find all require statements.
Relevant issue on Detective: https://github.com/substack/node-detective/issues/8
I've successfully used Detective in a couple of my personal projects to find all require statements.
Relevant issue on Detective: https://github.com/substack/node-detective/issues/8
So i wouldn't call regex a 'very naive' choice, since people making it are aware of tradeoffs and pick regex intentionally.
Wether the choice was deliberate or not is debatable, but given the speed of these parsers I'd reason that there isn't any advantage to using regexes.
Reducing the amount of false positives is also one step closer to making this tool somewhat more secure, though certainly doesn't address any of the previous comments in this thread.
Then you can traverse it and modify it like any other AST.
[1] https://github.com/ternjs/acorn [2] http://esprima.org/ [3] https://github.com/estree/estree