Skip to content

Commit a29f8a0

Browse files
committed
Now using relative path instead of absolute one while making treenodes
1 parent 3f76047 commit a29f8a0

File tree

1 file changed

+14
-5
lines changed
  • rocket-chatter-ingestion-server/src/process/prepare/processor

1 file changed

+14
-5
lines changed

rocket-chatter-ingestion-server/src/process/prepare/processor/file.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,21 @@ export class FileProcessor implements IFileProcessor {
5555
.filter((node) => namedTypes.ImportDeclaration.check(node)) // Filter out all non-import nodes
5656
.filter((node) => (node as any).source.value.startsWith(".")) // Filter out all library/non-relative imports
5757
for (const i of imports) {
58-
const absolutePath = path.resolve(
59-
path.dirname(sourceFile.getFullPath()),
60-
(i as any).source.value + ".ts"
61-
)
6258
const importName = (i as any).specifiers[0].local.name
6359

60+
const sourceFileAbsolutePath = path
61+
.resolve(sourceFile.getFullPath())
62+
.replace(/\\/g, "/")
63+
const projectPath = sourceFileAbsolutePath.slice(
64+
0,
65+
sourceFileAbsolutePath.indexOf(sourceFile.getFullPath())
66+
)
67+
68+
const targetFileRelativePath = path
69+
.resolve(path.join(sourceFile.getFullPath(), (i as any).source.value))
70+
.replace(/\\/g, "/")
71+
const absolutePath = targetFileRelativePath.slice(projectPath.length)
72+
6473
parsedImports.set(importName, absolutePath)
6574
}
6675
}
@@ -72,7 +81,7 @@ export class FileProcessor implements IFileProcessor {
7281
.filter((x) => x.name)
7382
.map((x) => {
7483
if (parsedImports.has(x.name)) {
75-
x.name = parsedImports.get(x.name)!
84+
x.name = `${parsedImports.get(x.name)!}:${x.name}`
7685
}
7786
return x
7887
})

0 commit comments

Comments
 (0)