Skip to content

Commit

Permalink
Remove process.exit calls from publish-npm and throw errors instead (f…
Browse files Browse the repository at this point in the history
…acebook#43039)

Summary:

Changelog: [Internal] - `publish-npm.js` is a [script we call in our CI](https://www.internalfb.com/code/fbsource/[c0b8566ac0d66c2c0282eeb597bfb54bedf757c6]/xplat/js/react-native-github/.circleci/configurations/jobs.yml?lines=1243) to publish the react-native package and others.

Currently, the script leverages `exit/process.exit` to terminate early in a couple of places which makes the code hard to test because our tests don't truly early exit when `exit/process.exit` is called.

This change removes any explicit `exit` calls and instead leverages the uncaught error to terminate the process and set the non-zero exit code. This makes our tests more accurate to the real control flow of the script.

I've also updated the tests to better capture what we're actually testing by mocking at a higher level.

Reviewed By: cipolleschi

Differential Revision: D53792754
  • Loading branch information
lunaleaps authored and facebook-github-bot committed Feb 15, 2024
1 parent 2091400 commit d9a1533
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 186 deletions.
Loading

0 comments on commit d9a1533

Please sign in to comment.