mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
fix(scripts): validate i18n bundle dist flag (#3071)
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
co-authored by
Steven Enamakel
parent
c0cccb14e5
commit
468793b828
@@ -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/);
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user