fix: parse packaged telemetry sync defaults correctly
This commit is contained in:
@@ -71,8 +71,6 @@ function isNodeError(error) {
|
|||||||
function parseArgs(args) {
|
function parseArgs(args) {
|
||||||
const parsed = {
|
const parsed = {
|
||||||
check: false,
|
check: false,
|
||||||
sourceDir: DEFAULT_SOURCE_DIR,
|
|
||||||
componentDir: DEFAULT_COMPONENT_DIR,
|
|
||||||
};
|
};
|
||||||
for (let index = 0; index < args.length; index += 1) {
|
for (let index = 0; index < args.length; index += 1) {
|
||||||
const arg = args[index];
|
const arg = args[index];
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import assert from "node:assert/strict";
|
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 { tmpdir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
import test from "node:test";
|
import test from "node:test";
|
||||||
|
|
||||||
const SCRIPT_PATH = new URL("./sync-telemetry-component.mjs", import.meta.url);
|
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 });
|
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 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user