From 4089bb4d35548eb06a1defd6ee47ce23ca359a09 Mon Sep 17 00:00:00 2001 From: Pavlo Radiev <96287075+pradiev@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:29:10 +0200 Subject: [PATCH] fix: ignore import path transformations on win32 platform (#570) * fix: ignore import path transformations on win32 platform * fix: fixed a "code smell" to pass the code analysis --- packages/classes/transformer-plugin/src/lib/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/classes/transformer-plugin/src/lib/utils.ts b/packages/classes/transformer-plugin/src/lib/utils.ts index 370eb6a0a..c5d93a590 100644 --- a/packages/classes/transformer-plugin/src/lib/utils.ts +++ b/packages/classes/transformer-plugin/src/lib/utils.ts @@ -39,7 +39,7 @@ export function getDecoratorOrUndefinedByNames( names: string[], decorators?: readonly Decorator[] ): Decorator | undefined { - return (decorators || []).find((item) => + return (decorators ? decorators : []).find((item) => names.includes(getDecoratorName(item) as string) ); } @@ -110,6 +110,11 @@ export function replaceImportPath( if (!importPath) { return undefined; } + + if (process.platform === 'win32') { + return typeReference.replace('import', 'require') + } + importPath = importPath.slice(2, importPath.length - 1); let relativePath = posix.relative(dirname(fileName), importPath);