This commit is contained in:
@@ -6,10 +6,15 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
const webRoot = join(fileURLToPath(new URL('..', import.meta.url)));
|
||||
const scriptArgument = process.argv[2];
|
||||
const argumentsAfterCommand = process.argv.slice(2);
|
||||
const scriptArgument = argumentsAfterCommand.find((argument) => !argument.startsWith('--'));
|
||||
const expectedCountArgument = argumentsAfterCommand.find((argument) => argument.startsWith('--expected-count='));
|
||||
const expectedCount = expectedCountArgument
|
||||
? Number(expectedCountArgument.slice('--expected-count='.length))
|
||||
: 3;
|
||||
|
||||
if (!scriptArgument) {
|
||||
throw new Error('Usage: node scripts/audit-editorial-draft.mjs <revision-script.mjs>');
|
||||
if (!scriptArgument || !Number.isInteger(expectedCount) || expectedCount < 1) {
|
||||
throw new Error('Usage: node scripts/audit-editorial-draft.mjs <revision-script.mjs> [--expected-count=N]');
|
||||
}
|
||||
|
||||
const scriptPath = isAbsolute(scriptArgument)
|
||||
@@ -65,8 +70,8 @@ try {
|
||||
const imported = await import(pathToFileURL(scriptPath).href);
|
||||
const revisions = imported.revisions;
|
||||
|
||||
if (!Array.isArray(revisions) || revisions.length !== 3) {
|
||||
throw new Error('Module must export exactly three revisions');
|
||||
if (!Array.isArray(revisions) || revisions.length !== expectedCount) {
|
||||
throw new Error('Module must export exactly ' + expectedCount + ' revision(s)');
|
||||
}
|
||||
|
||||
if (JSON.stringify(cliRevisions) !== JSON.stringify(revisions)) {
|
||||
|
||||
Reference in New Issue
Block a user