File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,21 @@ function collectTestRequires(node) {
356
356
if ( s . local && s . local . name ) requireData . functionNames . push ( s . local . name )
357
357
} )
358
358
359
+ requires . push ( requireData ) ;
360
+ }
361
+ } ,
362
+ CallExpression ( path ) {
363
+ if ( path . node . callee . name === 'require' && path . node . arguments && path . node . arguments . length > 0 ) {
364
+ const requireData = {
365
+ code : generator ( path . node ) . code ,
366
+ functionNames : [ ]
367
+ }
368
+
369
+ // In case of a CommonJS require, the function name is usually the variable identifier of the parent node
370
+ if ( path . parentPath && path . parentPath . node . type === 'VariableDeclarator' && path . parentPath . node . id ) {
371
+ requireData . functionNames . push ( path . parentPath . node . id . name )
372
+ }
373
+
359
374
requires . push ( requireData ) ;
360
375
}
361
376
}
You can’t perform that action at this time.
0 commit comments