diff options
Diffstat (limited to 'babel-import-promise/babel-import-promise.mjs')
-rw-r--r-- | babel-import-promise/babel-import-promise.mjs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/babel-import-promise/babel-import-promise.mjs b/babel-import-promise/babel-import-promise.mjs index 24cc28f..8d96eab 100644 --- a/babel-import-promise/babel-import-promise.mjs +++ b/babel-import-promise/babel-import-promise.mjs @@ -30,16 +30,17 @@ export default function ({ types: t }) { const MyVisitor2 = { Identifier(path) { if (path.node.name === "fetch") { - shouldAdd = true + shouldAdd2 = true } } }; + path.traverse(MyVisitor2) - if (shouldAdd2) { - let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 3 + if (shouldAdd2 && !state.filename.includes("networkUtils")) { + let depth = state.filename.replace(state.cwd, "").split(/[\\/]/g).length - 2 const identifier = t.identifier('fetch'); const importDefaultSpecifier = t.importDefaultSpecifier(identifier); - const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'utils/networkUtils')); + const importDeclaration = t.importDeclaration([importDefaultSpecifier], t.stringLiteral("../".repeat(depth) + 'SoopyV2/utils/networkUtils')); path.unshiftContainer('body', importDeclaration); } } |