Skip to content

Commit c4e7140

Browse files
committed
fix: not working for same or lower directory level
closes #2
1 parent b6d54f7 commit c4e7140

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
lib
22
node_modules
3-
tests/core/index.js
4-
tests/utils/sum.js
3+
tests/**/*.js

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from "typescript";
1+
import ts from "typescript";
22
import { dirname, resolve, relative } from "path";
33

44
const transformer = <T extends ts.Node>(_: ts.Program) => {
@@ -28,7 +28,8 @@ const transformer = <T extends ts.Node>(_: ts.Program) => {
2828
if (match) {
2929
const out = path.resolve.replace(/\*/g, match[1]);
3030
const file = relative(fileDir, resolve(baseUrl, out));
31-
node.moduleSpecifier.text = file;
31+
// If it's in the same level or below add the ./
32+
node.moduleSpecifier.text = file[0] === "." ? file : `./${file}`;
3233
break;
3334
}
3435
}

tests/core/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { sum } from "@utils/sum";
2+
import { subs } from "@utils/subs";
23

3-
sum(2, 3)
4+
sum(2, 3);
5+
subs(2, 3);

tests/utils/subs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { sum } from "@utils/sum";
2+
3+
export function subs(a: number, b: number) {
4+
return sum(a, -b);
5+
}

0 commit comments

Comments
 (0)