From 2020b4e189fac02c1b5809522d25bc836d857930 Mon Sep 17 00:00:00 2001 From: Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> Date: Sun, 18 Sep 2022 09:22:18 +0800 Subject: + convert command for ordered waypoints --- babel-import-promise/babel-import-promise.mjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'babel-import-promise/babel-import-promise.mjs') 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); } } -- cgit