Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

releasePublish uses process.exit making it unsuitable for programmatic use #21321

Closed
4 tasks
jeffora opened this issue Jan 25, 2024 · 4 comments
Closed
4 tasks
Assignees
Labels

Comments

@jeffora
Copy link

jeffora commented Jan 25, 2024

Current Behavior

When using releasePublish programmatically via import { releasePublish } from 'nx/release;, successful invocations will result in the method calling process.exit(0), while errors call process.exit(1). This makes this unsuitable for programmatic consumption, as it is not possible to try/catch errors, or perform additional tasks after successfully running.

E.g., the following code does not work (does not print the logged line):

import { releasePublish } from 'nx/release';

await releasePublish({ projects: ['my-project'] });
console.log('Publishing successful');

Expected Behavior

To support programmatic consumption, the method releasePublish should throw errors or return results. A CLI wrapper could easily convert these into process.exit commands but allow programmatic consumers to perform their own error handling and clean up tasks.

GitHub Repo

No response

Steps to Reproduce

import { releasePublish } from 'nx/release';

await releasePublish({ projects: ['my-project'] });
console.log('Publishing successful');

Nx Report

NA

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder added the scope: core core nx functionality label Jan 28, 2024
@JamesHenry
Copy link
Collaborator

Thanks @jeffora, this has already been addressed in #21338 and is available in the 17.3 RC

@jeffora
Copy link
Author

jeffora commented Jan 28, 2024

Thanks @JamesHenry that's great. I'll take a look at the RC and revert our workaround

@JamesHenry
Copy link
Collaborator

Cool, thanks @jeffora - please note there was a regression this introduced for the CLI usage, fixed here: #21388

Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants