diff --git a/skills/reverse-engineering-saas/scripts/check-kb.mjs b/skills/reverse-engineering-saas/scripts/check-kb.mjs index 4d00f7e..e7e34d3 100644 --- a/skills/reverse-engineering-saas/scripts/check-kb.mjs +++ b/skills/reverse-engineering-saas/scripts/check-kb.mjs @@ -3,7 +3,7 @@ // evidence tags, the change ledger and STATUS.md. // Exit code 1 when there are errors, 2 on bad usage. import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'; -import { dirname, join, relative, resolve } from 'node:path'; +import { dirname, join, relative, resolve, sep } from 'node:path'; const USAGE = 'Usage: node check-kb.mjs [--closing] [--next] [--help]'; const ID_PATTERN = /\b(FL|SRC|EV|BR|F|S|C|R|E|B|Q|L)-(\d{3})\b/g; @@ -46,7 +46,7 @@ function walk(dir, root = dir) { if (SKIP_DIRS.has(entry)) continue; const full = join(dir, entry); if (statSync(full).isDirectory()) files.push(...walk(full, root)); - else files.push(relative(root, full)); + else files.push(relative(root, full).split(sep).join('/')); } return files; } diff --git a/tests/kb-scripts.test.mjs b/tests/kb-scripts.test.mjs index 3b912eb..538120a 100644 --- a/tests/kb-scripts.test.mjs +++ b/tests/kb-scripts.test.mjs @@ -9,6 +9,8 @@ import { fileURLToPath } from 'node:url'; const scripts = join(dirname(fileURLToPath(import.meta.url)), '..', 'skills', 'reverse-engineering-saas', 'scripts'); const run = (name, ...args) => spawnSync(process.execPath, [join(scripts, name), ...args], { encoding: 'utf8' }); +// Windows installs Python as python, not python3. +const python = process.platform === 'win32' ? 'python' : 'python3'; let dir; let kb; @@ -218,7 +220,7 @@ test('init-kb defaults to ./re-', () => { // Lists and verifies a zip with Python's zipfile, an independent implementation. const readZip = (file) => { const code = 'import json,sys,zipfile\nz=zipfile.ZipFile(sys.argv[1])\nprint(json.dumps({"bad": z.testzip(), "names": z.namelist(), "build": z.read([n for n in z.namelist() if n.endswith("/BUILD.md")][0]).decode()}))'; - const result = spawnSync('python3', ['-c', code, file], { encoding: 'utf8' }); + const result = spawnSync(python, ['-c', code, file], { encoding: 'utf8' }); assert.equal(result.status, 0, result.stderr); return JSON.parse(result.stdout); }; @@ -255,7 +257,7 @@ test('an unzipped handoff passes check-kb --closing; its ledger has no IDs, loca assert.equal(packed.status, 0, packed.stdout + packed.stderr); assert.match(packed.stdout, /Kept sandbox\/ledger\.csv without object IDs/); const target = join(dir, 'unzipped'); - const unzip = spawnSync('python3', ['-c', 'import sys,zipfile\nzipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])', out, target], { encoding: 'utf8' }); + const unzip = spawnSync(python, ['-c', 'import sys,zipfile\nzipfile.ZipFile(sys.argv[1]).extractall(sys.argv[2])', out, target], { encoding: 'utf8' }); assert.equal(unzip.status, 0, unzip.stderr); const ledger = readFileSync(join(target, 're-acme', 'sandbox', 'ledger.csv'), 'utf8');