fix: parse packaged telemetry sync defaults correctly

This commit is contained in:
YeonGyu-Kim
2026-05-31 00:26:10 +09:00
parent 7c979f894d
commit a0bea3a415
2 changed files with 25 additions and 3 deletions
@@ -71,8 +71,6 @@ function isNodeError(error) {
function parseArgs(args) {
const parsed = {
check: false,
sourceDir: DEFAULT_SOURCE_DIR,
componentDir: DEFAULT_COMPONENT_DIR,
};
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
@@ -1,7 +1,8 @@
import assert from "node:assert/strict";
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { spawnSync } from "node:child_process";
import test from "node:test";
const SCRIPT_PATH = new URL("./sync-telemetry-component.mjs", import.meta.url);
@@ -68,3 +69,26 @@ test("#given a missing pure telemetry source file #when sync runs #then it fails
await rm(root, { recursive: true, force: true });
}
});
test("#given packaged default layout without pure telemetry source #when cli sync runs #then it exits cleanly", async () => {
// given
const root = await makeTempDir();
const scriptPath = join(root, "packages", "omo-codex", "scripts", "sync-telemetry-component.mjs");
await mkdir(join(root, "packages", "omo-codex", "scripts"), { recursive: true });
await cp(new URL("./sync-telemetry-component.mjs", import.meta.url), scriptPath);
try {
// when
const result = spawnSync(process.execPath, [scriptPath], {
encoding: "utf8",
env: {
...process.env,
},
});
// then
assert.equal(result.status, 0, result.stderr);
} finally {
await rm(root, { recursive: true, force: true });
}
});