Skip to content

Commit

Permalink
fix(plugin): transform absolute paths #1411
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jun 30, 2021
1 parent fe98e6a commit ae70da9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/plugin/utils/plugin-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { head } from 'lodash';
import { posix } from 'path';
import { isAbsolute, posix } from 'path';
import * as ts from 'typescript';
import {
getDecoratorName,
Expand Down Expand Up @@ -123,7 +123,10 @@ export function replaceImportPath(typeReference: string, fileName: string) {
importPath = importPath.slice(2, importPath.length - 1);

try {
require.resolve(importPath)
if (isAbsolute(importPath)) {
throw {};
}
require.resolve(importPath);
return typeReference.replace('import', 'require');
} catch (_error) {
let relativePath = posix.relative(posix.dirname(fileName), importPath);
Expand Down

0 comments on commit ae70da9

Please sign in to comment.