From 810810777910349f74cee88bbc7732d7710cd327 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 28 Dec 2023 13:40:11 +0800 Subject: [PATCH] fix: require module (#3277) * fix: require module * fix: include utils --- .github/workflows/nocobase-test-backend.yml | 2 ++ packages/core/utils/src/requireModule.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/nocobase-test-backend.yml b/.github/workflows/nocobase-test-backend.yml index 0f90c02e9..34e97e4e3 100644 --- a/.github/workflows/nocobase-test-backend.yml +++ b/.github/workflows/nocobase-test-backend.yml @@ -11,6 +11,7 @@ on: - 'packages/core/actions/**' - 'packages/core/database/**' - 'packages/core/server/**' + - 'packages/core/utils/**' - 'packages/plugins/**/src/server/**' - '.github/workflows/nocobase-test-backend.yml' pull_request: @@ -20,6 +21,7 @@ on: - 'packages/core/actions/**' - 'packages/core/database/**' - 'packages/core/server/**' + - 'packages/core/utils/**' - 'packages/plugins/**/src/server/**' - '.github/workflows/nocobase-test-backend.yml' diff --git a/packages/core/utils/src/requireModule.ts b/packages/core/utils/src/requireModule.ts index 8b2d3da31..d3c2ae69b 100644 --- a/packages/core/utils/src/requireModule.ts +++ b/packages/core/utils/src/requireModule.ts @@ -16,6 +16,10 @@ export function requireModule(m: any) { export default requireModule; export async function importModule(m: string) { + if (!process.env.VITEST) { + return requireModule(m); + } + if (path.isAbsolute(m)) { m = pathToFileURL(m).href; }