Skip to content

Commit

Permalink
adding recursive traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekbh committed Jan 13, 2020
1 parent d197ae8 commit f94eb3e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
IGetAstNodeResult,
NodeInspector,
} from './TestInterface'
// import { Node } from './ASTInterface';
//import {NodePath, ASTNode} from 'ast-types';
import { NodePath } from 'ast-types/lib/node-path'
import { visit } from 'recast'

Expand Down Expand Up @@ -115,17 +113,19 @@ export default class WebpackConformancePlugin {
.tap(this.constructor.name, parser => {
parser.hooks.program.tap(this.constructor.name, (ast: any) => {
const visitors: VisitorMap = {}
const that = this
for (const visitorKey of collectedVisitors.keys()) {
visitors[visitorKey] = (path: NodePath) => {
visitors[visitorKey] = function(path: NodePath) {
const callbacks = collectedVisitors.get(visitorKey) || []
callbacks.forEach(cb => {
if (!cb) {
return
}
const { request } = parser.state.module
const outcome = cb(path, { request })
this.gatherResults([outcome])
that.gatherResults([outcome])
})
this.traverse(path)
return false
}
}
Expand Down

0 comments on commit f94eb3e

Please sign in to comment.