tools: dev CLI dispatcher handles sync commands (build/test no longer crash) (#801)
commands[cmd]().catch(...) assumed every command returns a promise; the sync ones (build mac/ios, test*) return undefined and crashed the dispatcher with '.catch of undefined' before doing anything — Promise.resolve-wrap so both shapes get the same failure handling. Found while building #582 (flagged in PR #791).
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 file changed,
+3
−1
tools/dev+3 −1
diff --git a/tools/dev b/tools/dev| index 04900ee..c4a1529 100755 |
| --- a/tools/dev |
| +++ b/tools/dev |
| @@ -374,7 +374,9 @@ if (!cmd || cmd === "-h" || cmd === "--help" || cmd === "help") { |
| } |
| if (commands[cmd]) { |
| - commands[cmd]().catch((e) => { |
| + // Some commands are sync (build/test) and return undefined — wrap, so the |
| + // failure handler works for both instead of crashing on `.catch`. |
| + Promise.resolve(commands[cmd]()).catch((e) => { |
| console.error(`Error: ${e.message}`); |
| process.exit(1); |
| }); |