fix(build): honor postinstall disable flag

This commit is contained in:
Ayaan Zaidi
2026-04-08 20:51:08 +05:30
parent 66ec8909bd
commit f4ec59c431
2 changed files with 20 additions and 0 deletions

View File

@@ -154,6 +154,9 @@ export function runBundledPluginPostinstall(params = {}) {
const spawn = params.spawnSync ?? spawnSync;
const pathExists = params.existsSync ?? existsSync;
const log = params.log ?? console;
if (env?.[DISABLE_POSTINSTALL_ENV]?.trim()) {
return;
}
if (isSourceCheckoutRoot({ packageRoot, existsSync: pathExists })) {
try {
pruneBundledPluginSourceNodeModules({

View File

@@ -157,6 +157,23 @@ describe("bundled plugin postinstall", () => {
);
});
it("honors disable env before source-checkout pruning", async () => {
const packageRoot = await createTempDirAsync("openclaw-source-checkout-disabled-");
const extensionsDir = path.join(packageRoot, "extensions");
await fs.mkdir(path.join(packageRoot, ".git"), { recursive: true });
await fs.mkdir(path.join(packageRoot, "src"), { recursive: true });
await fs.mkdir(path.join(extensionsDir, "acpx", "node_modules"), { recursive: true });
await fs.writeFile(path.join(extensionsDir, "acpx", "package.json"), "{}\n");
runBundledPluginPostinstall({
env: { OPENCLAW_DISABLE_BUNDLED_PLUGIN_POSTINSTALL: "1" },
packageRoot,
log: { log: vi.fn(), warn: vi.fn() },
});
await expect(fs.stat(path.join(extensionsDir, "acpx", "node_modules"))).resolves.toBeTruthy();
});
it("runs nested local installs with sanitized env when the sentinel package is missing", async () => {
const extensionsDir = await createExtensionsDir();
const packageRoot = path.dirname(path.dirname(extensionsDir));