mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
fix(build): keep tsdown prune best-effort
This commit is contained in:
@@ -47,17 +47,22 @@ function pruneStaleRuntimeSymlinks() {
|
||||
removeDistPluginNodeModulesSymlinks(path.join(cwd, "dist-runtime"));
|
||||
}
|
||||
|
||||
function pruneSourceCheckoutBundledPluginNodeModules() {
|
||||
const cwd = process.cwd();
|
||||
export function pruneSourceCheckoutBundledPluginNodeModules(params = {}) {
|
||||
const cwd = params.cwd ?? process.cwd();
|
||||
const logger = params.logger ?? console;
|
||||
if (!isSourceCheckoutRoot({ packageRoot: cwd, existsSync: fs.existsSync })) {
|
||||
return;
|
||||
}
|
||||
pruneBundledPluginSourceNodeModules({
|
||||
extensionsDir: path.join(cwd, "extensions"),
|
||||
existsSync: fs.existsSync,
|
||||
readdirSync: fs.readdirSync,
|
||||
rmSync: fs.rmSync,
|
||||
});
|
||||
try {
|
||||
pruneBundledPluginSourceNodeModules({
|
||||
extensionsDir: path.join(cwd, "extensions"),
|
||||
existsSync: fs.existsSync,
|
||||
readdirSync: fs.readdirSync,
|
||||
rmSync: fs.rmSync,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.warn(`tsdown: could not prune bundled plugin source node_modules: ${String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
function findFatalUnresolvedImport(lines) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveTsdownBuildInvocation } from "../../scripts/tsdown-build.mjs";
|
||||
import fs from "node:fs";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
pruneSourceCheckoutBundledPluginNodeModules,
|
||||
resolveTsdownBuildInvocation,
|
||||
} from "../../scripts/tsdown-build.mjs";
|
||||
|
||||
describe("resolveTsdownBuildInvocation", () => {
|
||||
it("routes Windows tsdown builds through the pnpm runner instead of shell=true", () => {
|
||||
@@ -30,4 +34,26 @@ describe("resolveTsdownBuildInvocation", () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps source-checkout prune best-effort", () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const rmSync = vi.spyOn(fs, "rmSync");
|
||||
|
||||
rmSync.mockImplementation(() => {
|
||||
throw new Error("locked");
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
pruneSourceCheckoutBundledPluginNodeModules({
|
||||
cwd: process.cwd(),
|
||||
}),
|
||||
).not.toThrow();
|
||||
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"tsdown: could not prune bundled plugin source node_modules: Error: locked",
|
||||
);
|
||||
|
||||
warn.mockRestore();
|
||||
rmSync.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user