aboutsummaryrefslogtreecommitdiff
path: root/babel-import-promise
diff options
context:
space:
mode:
Diffstat (limited to 'babel-import-promise')
-rw-r--r--babel-import-promise/babel-import-promise.mjs17
1 files changed, 17 insertions, 0 deletions
diff --git a/babel-import-promise/babel-import-promise.mjs b/babel-import-promise/babel-import-promise.mjs
index 10aee6a..24cc28f 100644
--- a/babel-import-promise/babel-import-promise.mjs
+++ b/babel-import-promise/babel-import-promise.mjs
@@ -25,6 +25,23 @@ export default function ({ types: t }) {
const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'PromiseV2'));
path.unshiftContainer('body', importDeclaration);
}
+
+ let shouldAdd2 = false
+ const MyVisitor2 = {
+ Identifier(path) {
+ if (path.node.name === "fetch") {
+ shouldAdd = true
+ }
+ }
+ };
+ path.traverse(MyVisitor2)
+ if (shouldAdd2) {
+ let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 3
+ const identifier = t.identifier('fetch');
+ const importDefaultSpecifier = t.importDefaultSpecifier(identifier);
+ const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'utils/networkUtils'));
+ path.unshiftContainer('body', importDeclaration);
+ }
}
}
};