Skip to content

Commit 6d25856

Browse files
committed
fix: improve /index.js import removal to preserve relative imports
1 parent 882fb67 commit 6d25856

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adminforth/commands/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ function processJsFilesInDir(directory) {
8282
}
8383
);
8484

85-
// Remove /index.js from imports
85+
// Remove /index.js from imports only if it's not a relative path
8686
fileContent = fileContent.replace(
8787
/import (.+?) from ["'](.+?)\/index\.js["'];/g,
8888
(match, imports, modulePath) => {
89-
return `import ${imports} from "${modulePath}";`;
89+
// Check if the path is not relative (doesn't start with ./ or ../)
90+
if (!modulePath.startsWith("./") && !modulePath.startsWith("../")) {
91+
return `import ${imports} from "${modulePath}";`;
92+
}
93+
return match;
9094
}
9195
);
9296

0 commit comments

Comments
 (0)