Repository navigation
Conversation
| closeEv.catch(() => {}) | ||
|
|
||
| const chunks = await Promise.race([ | ||
| once(cp, 'error').then(e => Promise.reject(e[0])), |
There was a problem hiding this comment.
once already returns a promise and:
rejected if the EventEmitter emits 'error' while waiting
So this is unnecessary, in fact, since you're taking inspiration from nodejs/changelog-maker#290 maybe you should just copy the simplified pipeline from there and adapt it to here because this code is complicated enough for me to suggest that keeping a dependency around is worth it to save the complexity.
There was a problem hiding this comment.
I know that once returns a promise, the code wouldn't work if it were returning something else, I don't understand why you're pointing it out.
| for await (const commit of source) { | ||
| commitList.push(commit) | ||
| await Promise.race([ | ||
| once(cp, 'error').then(e => Promise.reject(e[0])), |
There was a problem hiding this comment.
also in the spirit of "maybe just keep the dependency", you've got the same pattern essentially repeated twice in here now, too much unnecessary spaghetti, either leave it alone or make a helper that does a clean job -> spawn, collect, handle errors, basically replacing the dependency with a compact helper that justifies the replacement by not being too long
| ]) | ||
| const [code, signal] = await closeEv | ||
| if (code !== 0) { | ||
| throw new Error(`Command "git merge-base ${branch1} ${branch2}" exited with code ${code} and signal ${signal}`) |
There was a problem hiding this comment.
look at the error msg in changelog-maker PR, we only get a signal || code, not everything, most of the time it'll say "and signal null"
In the spirit of nodejs/changelog-maker#290, simplifies the dependency tree