Skip to content
Merged
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
2 changes: 1 addition & 1 deletion tools/loop-sync/dist/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function parseArgs(argv) {
else if (!a.startsWith('-'))
targetDir = a;
}
return { targetDir, autoFix, dryRun, verbose, help };
return { targetDir, autoFix, dryRun, verbose, help, json };
}
async function main() {
const args = parseArgs(process.argv.slice(2));
Expand Down
4 changes: 2 additions & 2 deletions tools/loop-sync/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function parseArgs(argv: string[]): SyncOptions {
else if (!a.startsWith('-')) targetDir = a;
}

return { targetDir, autoFix, dryRun, verbose, help };
return { targetDir, autoFix, dryRun, verbose, help, json };
}

async function main() {
Expand Down Expand Up @@ -86,4 +86,4 @@ Docs: https://github.com/cobusgreyling/loop-engineering/tree/main/tools/loop-syn
}
}

main();
main();
27 changes: 26 additions & 1 deletion tools/loop-sync/test/sync.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { test, describe, beforeEach, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'node:path';
import { mkdir, writeFile, rm } from 'node:fs/promises';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
import { runSync, formatReport } from '../dist/sync.js';

const testDir = path.join(process.cwd(), '.test-tmp');
const exec = promisify(execFile);
const CLI = path.resolve('dist/cli.js');

async function setupTestDir() {
await mkdir(testDir, { recursive: true });
Expand Down Expand Up @@ -112,4 +116,25 @@ describe('formatReport', () => {
assert.match(formatted, /AGENTS\.md/);
assert.match(formatted, /missing/i);
});
});
});

describe('cli', () => {
beforeEach(setupTestDir);
afterEach(cleanupTestDir);

test('emits JSON when --json is provided', async () => {
let stdout;
try {
({ stdout } = await exec('node', [CLI, testDir, '--json']));
} catch (err) {
stdout = err.stdout;
assert.equal(err.code, 2);
}
const report = JSON.parse(stdout);

assert.equal(typeof report.score, 'number');
assert.ok(['healthy', 'warning', 'critical'].includes(report.level));
assert.ok(Array.isArray(report.issues));
assert.ok(Array.isArray(report.suggestions));
});
});