Skip to content

Commit 37a3396

Browse files
feat: callback on file
1 parent eb563d9 commit 37a3396

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ module.exports = (src, options = {}) => {
3030

3131
const walker = new Walker(walkerOptions);
3232

33-
walker.walk(src, (node) => {
33+
const ast = typeof src === 'string' ? walker.parse(src) : src;
34+
35+
if (options.onFile) {
36+
options.onFile({ options, src, ast, walker });
37+
}
38+
39+
walker.walk(ast, (node) => {
3440
switch (node.type) {
3541
case 'ImportExpression':
3642
if (!options.skipAsyncImports && node.source && node.source.value) {
@@ -83,6 +89,11 @@ module.exports = (src, options = {}) => {
8389
}
8490
});
8591

92+
93+
if (options.onAfterFile) {
94+
options.onAfterFile({ options, src, ast, walker, dependencies });
95+
}
96+
8697
return dependencies;
8798
};
8899

0 commit comments

Comments
 (0)