mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:40:43 +00:00
test: stabilize plugin sdk facade failure fixtures
This commit is contained in:
@@ -56,11 +56,15 @@ function createTrustedBundledPluginsRoot(kind: "dist" | "dist-runtime" = "dist")
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
function writeFixturePackageJson(pluginRoot: string, pluginId: string): void {
|
||||
function writeFixturePackageJson(
|
||||
pluginRoot: string,
|
||||
pluginId: string,
|
||||
type: "commonjs" | "module" = "module",
|
||||
): void {
|
||||
writeJsonFile(path.join(pluginRoot, "package.json"), {
|
||||
name: `@openclaw/${pluginId}`,
|
||||
version: "0.0.0",
|
||||
type: "module",
|
||||
type,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +112,7 @@ function createThrowingPluginFixture(prefix: string): TrustedBundledPluginFixtur
|
||||
const pluginRoot = path.join(bundledPluginsDir, pluginId);
|
||||
fs.mkdirSync(pluginRoot, { recursive: true });
|
||||
trustedBundledPluginFixtureRoots.push(pluginRoot);
|
||||
writeFixturePackageJson(pluginRoot, pluginId);
|
||||
writeFixturePackageJson(pluginRoot, pluginId, "commonjs");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginRoot, "api.js"),
|
||||
'throw new Error("plugin load failure");\n',
|
||||
|
||||
@@ -36,11 +36,15 @@ function createTrustedBundledFixtureRoot(prefix: string): string {
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
function writePluginPackageJson(pluginDir: string, name = "demo"): void {
|
||||
function writePluginPackageJson(
|
||||
pluginDir: string,
|
||||
name = "demo",
|
||||
type: "commonjs" | "module" = "module",
|
||||
): void {
|
||||
writeJsonFile(path.join(pluginDir, "package.json"), {
|
||||
name: `@openclaw/plugin-${name}`,
|
||||
version: "0.0.0",
|
||||
type: "module",
|
||||
type,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +70,7 @@ function createThrowingPluginDir(prefix: string): string {
|
||||
const rootDir = createTrustedBundledFixtureRoot(prefix);
|
||||
const pluginDir = path.join(rootDir, "bad");
|
||||
fs.mkdirSync(pluginDir, { recursive: true });
|
||||
writePluginPackageJson(pluginDir, "bad");
|
||||
writePluginPackageJson(pluginDir, "bad", "commonjs");
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "api.js"),
|
||||
`throw new Error("plugin load failure");\n`,
|
||||
|
||||
Reference in New Issue
Block a user