mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-20 21:02:10 +08:00
fix(test): stabilize workspace package test imports
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { loadBundledPluginPublicSurfaceModuleSync } from "../plugin-sdk/facade-loader.js";
|
||||
import { resolveBundledPluginsDir } from "../plugins/bundled-dir.js";
|
||||
import {
|
||||
@@ -218,5 +218,22 @@ export function resolveRelativeWorkspacePackagePublicModuleId(params: {
|
||||
const relativePath = path
|
||||
.relative(path.dirname(fromFilePath), targetPath)
|
||||
.replaceAll(path.sep, "/");
|
||||
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
||||
const normalizedRelativePath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
||||
if (path.resolve(path.dirname(fromFilePath), normalizedRelativePath) !== targetPath) {
|
||||
return pathToFileURL(targetPath).href;
|
||||
}
|
||||
return normalizedRelativePath;
|
||||
}
|
||||
|
||||
export function resolveWorkspacePackagePublicModuleUrl(params: {
|
||||
packageName: string;
|
||||
artifactBasename: string;
|
||||
}): string {
|
||||
const targetPath = resolveVitestSourceModulePath(
|
||||
path.resolve(
|
||||
resolveWorkspacePackageDir(params.packageName),
|
||||
normalizeBundledPluginArtifactSubpath(params.artifactBasename),
|
||||
),
|
||||
);
|
||||
return pathToFileURL(targetPath).href;
|
||||
}
|
||||
|
||||
@@ -4,15 +4,14 @@ import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import { createEmptyPluginRegistry } from "../../../src/plugins/registry-empty.js";
|
||||
import { setActivePluginRegistry } from "../../../src/plugins/runtime.js";
|
||||
import type { SpeechProviderPlugin } from "../../../src/plugins/types.js";
|
||||
import { resolveRelativeWorkspacePackagePublicModuleId } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
import { resolveWorkspacePackagePublicModuleUrl } from "../../../src/test-utils/bundled-plugin-public-surface.js";
|
||||
import { withEnv } from "../../../src/test-utils/env.js";
|
||||
import type { ResolvedTtsConfig } from "../../../src/tts/tts-types.js";
|
||||
|
||||
type TtsRuntimeModule = typeof import("../../../src/tts/tts.js");
|
||||
type TtsCoreModule = typeof import("../../../src/tts/tts-core.js");
|
||||
|
||||
const speechCoreRuntimeApiModuleId = resolveRelativeWorkspacePackagePublicModuleId({
|
||||
fromModuleUrl: import.meta.url,
|
||||
const speechCoreRuntimeApiModuleId = resolveWorkspacePackagePublicModuleUrl({
|
||||
packageName: "@openclaw/speech-core",
|
||||
artifactBasename: "runtime-api.js",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user