Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions tests/check-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ const result = spawnSync("npm", ["pack", "--dry-run", "--json"], { cwd: packageR
if (result.stderr.length > 0) process.stderr.write(result.stderr);
assert.equal(result.status, 0, result.error?.message ?? result.stderr);

const firstJson = result.stdout.indexOf("[");
const lastJson = result.stdout.lastIndexOf("]");
assert.equal(firstJson >= 0 && lastJson >= firstJson, true, "npm pack did not emit JSON");
const parsed: unknown = JSON.parse(result.stdout.slice(firstJson, lastJson + 1));
assert.equal(Array.isArray(parsed), true, "npm pack JSON should be an array");
const manifest = parsed[0];
const parsed: unknown = JSON.parse(result.stdout.trim());
assert.equal(typeof parsed === "object" && parsed !== null, true, "npm pack did not emit JSON");
const manifest = Array.isArray(parsed) ? parsed[0] : Object.values(parsed as Record<string, unknown>)[0];
assert.equal(typeof manifest === "object" && manifest !== null && "files" in manifest, true, "npm pack JSON should include files");
const rawFiles = manifest.files;
assert.equal(Array.isArray(rawFiles), true, "npm pack files should be an array");
Expand Down
9 changes: 3 additions & 6 deletions tests/check-package-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,9 @@ async function assertSkillManifest(root: string, label: string, skills: unknown)
}

function parsePackTarballPath(stdout: string, destination: string): string {
const firstJson = stdout.indexOf("[");
const lastJson = stdout.lastIndexOf("]");
assert.equal(firstJson >= 0 && lastJson >= firstJson, true, "npm pack did not emit JSON");
const parsed: unknown = JSON.parse(stdout.slice(firstJson, lastJson + 1));
assert.equal(Array.isArray(parsed), true, "npm pack JSON should be an array");
const manifest: unknown = parsed[0];
const parsed: unknown = JSON.parse(stdout.trim());
assert.equal(typeof parsed === "object" && parsed !== null, true, "npm pack did not emit JSON");
const manifest: unknown = Array.isArray(parsed) ? parsed[0] : Object.values(parsed as Record<string, unknown>)[0];
if (!isRecord(manifest)) throw new Error("npm pack entry should be an object");
assert.equal(typeof manifest.filename, "string", "npm pack entry should include filename");
return join(destination, manifest.filename);
Expand Down