Browse Source

fix(cli): Fix relative import path for parent dirs

Michael Bromley 1 year ago
parent
commit
9379d7329c
1 changed files with 2 additions and 1 deletions
  1. 2 1
      packages/cli/src/utilities/ast-utils.ts

+ 2 - 1
packages/cli/src/utilities/ast-utils.ts

@@ -143,7 +143,8 @@ function convertPathToRelativeImport(filePath: string): string {
 
     // Remove the file extension
     const parsedPath = path.parse(normalizedPath);
-    return `./${parsedPath.dir}/${parsedPath.name}`.replace(/\/\//g, '/');
+    const prefix = parsedPath.dir.startsWith('..') ? '' : './';
+    return `${prefix}${parsedPath.dir}/${parsedPath.name}`.replace(/\/\//g, '/');
 }
 
 export function customizeCreateUpdateInputInterfaces(sourceFile: SourceFile, entityRef: EntityRef) {