fix(scripts): validate i18n bundle dist flag (#3071)

Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
Alexzhu
2026-06-01 17:18:09 -07:00
committed by GitHub
co-authored by Steven Enamakel
parent c0cccb14e5
commit 468793b828
2 changed files with 31 additions and 1 deletions
@@ -0,0 +1,30 @@
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, '..', 'verify-i18n-bundle.mjs');
function run(args) {
return spawnSync(process.execPath, [SCRIPT, ...args], {
encoding: 'utf8',
});
}
test('verify-i18n-bundle --dist rejects a missing path before filesystem checks', () => {
const result = run(['--dist']);
assert.equal(result.status, 2, result.stderr);
assert.match(result.stderr, /--dist requires a path/);
assert.doesNotMatch(result.stderr, /dist directory does not exist/);
});
test('verify-i18n-bundle --dist rejects another flag as the path value', () => {
const result = run(['--dist', '--help']);
assert.equal(result.status, 2, result.stderr);
assert.match(result.stderr, /--dist requires a path/);
assert.doesNotMatch(result.stderr, /dist directory does not exist/);
});
+1 -1
View File
@@ -10,7 +10,7 @@ for (let i = 2; i < process.argv.length; i += 1) {
const arg = process.argv[i];
if (arg === "--dist") {
const value = process.argv[i + 1];
if (!value) {
if (!value || value.startsWith("-")) {
console.error("verify-i18n-bundle: --dist requires a path");
process.exit(2);
}