mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
fix(scripts): make checklist help exit cleanly (#3067)
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
co-authored by
Steven Enamakel
parent
54fd16c0d0
commit
17a55818f9
@@ -0,0 +1,31 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import { dirname, resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import { test } from 'node:test';
|
||||||
|
|
||||||
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const SCRIPT = resolve(HERE, '..', 'check-pr-checklist.mjs');
|
||||||
|
|
||||||
|
function run(args, options = {}) {
|
||||||
|
return spawnSync(process.execPath, [SCRIPT, ...args], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
test('check-pr-checklist --help prints usage and exits 0', () => {
|
||||||
|
const result = run(['--help']);
|
||||||
|
|
||||||
|
assert.equal(result.status, 0, result.stderr);
|
||||||
|
assert.match(result.stdout, /Usage: check-pr-checklist\.mjs \[body-file\|-\]/);
|
||||||
|
assert.equal(result.stderr, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('check-pr-checklist -h prints usage and exits 0', () => {
|
||||||
|
const result = run(['-h']);
|
||||||
|
|
||||||
|
assert.equal(result.status, 0, result.stderr);
|
||||||
|
assert.match(result.stdout, /Usage: check-pr-checklist\.mjs \[body-file\|-\]/);
|
||||||
|
assert.equal(result.stderr, '');
|
||||||
|
});
|
||||||
@@ -2,10 +2,18 @@
|
|||||||
import { readFileSync } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { parseChecklist, summarize } from './lib/checklist-parser.mjs';
|
import { parseChecklist, summarize } from './lib/checklist-parser.mjs';
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
return 'Usage: check-pr-checklist.mjs [body-file|-]';
|
||||||
|
}
|
||||||
|
|
||||||
function readBody() {
|
function readBody() {
|
||||||
const [source, extra] = process.argv.slice(2);
|
const [source, extra] = process.argv.slice(2);
|
||||||
|
if (source === '--help' || source === '-h') {
|
||||||
|
console.log(usage());
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
if (extra) {
|
if (extra) {
|
||||||
console.error('Usage: check-pr-checklist.mjs [body-file|-]');
|
console.error(usage());
|
||||||
process.exit(2);
|
process.exit(2);
|
||||||
}
|
}
|
||||||
if (source === '-') {
|
if (source === '-') {
|
||||||
|
|||||||
Reference in New Issue
Block a user