Watchdog notice reader: start the verb after the module finishes initialising
The top-level await ran main() before the const declarations below it, so every process run died in the temporal dead zone with unexpected-error. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
417454c28f
commit
ef867f3e28
1 changed files with 7 additions and 7 deletions
|
|
@ -36,13 +36,6 @@ const SUBJECT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
||||||
class NoticeError extends Error {}
|
class NoticeError extends Error {}
|
||||||
const fail = (code) => new NoticeError(code);
|
const fail = (code) => new NoticeError(code);
|
||||||
|
|
||||||
try {
|
|
||||||
process.exitCode = await main(process.argv.slice(2));
|
|
||||||
} catch (error) {
|
|
||||||
process.stderr.write(`watchdog-notice: ${error instanceof NoticeError ? error.message : "unexpected-error"}\n`);
|
|
||||||
process.exitCode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main(args) {
|
async function main(args) {
|
||||||
const [verb, ...rest] = args;
|
const [verb, ...rest] = args;
|
||||||
const options = parseArgs(rest);
|
const options = parseArgs(rest);
|
||||||
|
|
@ -282,3 +275,10 @@ function requireOption(options, name) {
|
||||||
if (!options[name]) throw fail(`missing-option-${name}`);
|
if (!options[name]) throw fail(`missing-option-${name}`);
|
||||||
return options[name];
|
return options[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
process.exitCode = await main(process.argv.slice(2));
|
||||||
|
} catch (error) {
|
||||||
|
process.stderr.write(`watchdog-notice: ${error instanceof NoticeError ? error.message : "unexpected-error"}\n`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue