mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:40:44 +00:00
fix: accept extensionless runtime dependency mains
This commit is contained in:
@@ -80,7 +80,14 @@ function hasInstalledRuntimeDepEntryFiles(packageDir: string, packageJson: JsonO
|
||||
if (fs.existsSync(mainPath)) {
|
||||
return true;
|
||||
}
|
||||
return [".js", ".json", ".node"].some((extension) => fs.existsSync(`${mainPath}${extension}`));
|
||||
return (
|
||||
fs.existsSync(`${mainPath}.js`) ||
|
||||
fs.existsSync(`${mainPath}.json`) ||
|
||||
fs.existsSync(`${mainPath}.node`) ||
|
||||
fs.existsSync(path.join(mainPath, "index.js")) ||
|
||||
fs.existsSync(path.join(mainPath, "index.json")) ||
|
||||
fs.existsSync(path.join(mainPath, "index.node"))
|
||||
);
|
||||
}
|
||||
|
||||
export function isRuntimeDepSatisfied(
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getActiveBundledRuntimeDepsInstallCount,
|
||||
waitForBundledRuntimeDepsInstallIdle,
|
||||
} from "./bundled-runtime-deps-activity.js";
|
||||
import { assertBundledRuntimeDepsInstalled } from "./bundled-runtime-deps-materialization.js";
|
||||
import {
|
||||
__testing as bundledRuntimeDepsTesting,
|
||||
createBundledRuntimeDependencyAliasMap,
|
||||
@@ -1291,6 +1292,20 @@ describe("scanBundledPluginRuntimeDeps config policy", () => {
|
||||
expect(result.conflicts).toEqual([]);
|
||||
});
|
||||
|
||||
it("accepts staged runtime deps whose package main relies on Node extension resolution", () => {
|
||||
const installRoot = makeTempDir();
|
||||
const packageDir = path.join(installRoot, "node_modules", "jszip");
|
||||
fs.mkdirSync(path.join(packageDir, "lib"), { recursive: true });
|
||||
fs.writeFileSync(
|
||||
path.join(packageDir, "package.json"),
|
||||
JSON.stringify({ name: "jszip", version: "3.10.1", main: "./lib/index" }),
|
||||
"utf8",
|
||||
);
|
||||
fs.writeFileSync(path.join(packageDir, "lib", "index.js"), "export default {};\n", "utf8");
|
||||
|
||||
expect(() => assertBundledRuntimeDepsInstalled(installRoot, ["jszip@^3.10.1"])).not.toThrow();
|
||||
});
|
||||
|
||||
it("reports staged package-level runtime deps as missing when the version is stale", () => {
|
||||
const packageRoot = setupPolicyPackageRoot();
|
||||
const env = { OPENCLAW_PLUGIN_STAGE_DIR: makeTempDir() };
|
||||
|
||||
Reference in New Issue
Block a user