fix(scripts): reject short flag extension memory values

This commit is contained in:
Vincent Koc
2026-06-21 22:25:24 +02:00
parent 36db108fc1
commit b77d6149e1
2 changed files with 17 additions and 2 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ export function parseArgs(argv) {
case "--extension":
case "-e": {
const next = args[index + 1];
if (!next) {
if (!next || next.startsWith("-")) {
throw new Error(`${arg} requires a value`);
}
options.extensions.push(next);
@@ -112,7 +112,7 @@ export function parseArgs(argv) {
break;
case "--json": {
const next = args[index + 1];
if (!next) {
if (!next || next.startsWith("-")) {
throw new Error(`${arg} requires a value`);
}
options.jsonPath = path.resolve(next);
@@ -103,6 +103,21 @@ describe("scripts/profile-extension-memory", () => {
}
});
it("rejects option-looking string flag values before scanning built plugin artifacts", () => {
for (const args of [
["--extension", "-h"],
["--json", "-h"],
]) {
const result = runProfileExtensionMemory(args);
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr).toContain(`[extension-memory] ${args[0]} requires a value`);
expect(result.stderr).not.toContain("dist/extensions");
expect(result.stderr).not.toContain("at ");
}
});
it("bounds noisy child output without losing RSS samples", () => {
const root = mkdtempSync(path.join(tmpdir(), "openclaw-extension-memory-test-"));
try {