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

Add support for Bun JavaScript Runtime #2377

Open
Whobeu opened this issue Nov 29, 2023 · 3 comments
Open

Add support for Bun JavaScript Runtime #2377

Whobeu opened this issue Nov 29, 2023 · 3 comments

Comments

@Whobeu
Copy link

Whobeu commented Nov 29, 2023

I have been experimenting with the new Bun JavaScript runtime and have found that yargs does not understand this new runtime. When referencing the $0 variable in yargs, it return "bun" instead of the script being run. As a quick hack, I modified index.cjs to include "bun" to the Regex statement:

/\b(node|iojs|electron)(\.exe)?$/

which becomes

/\b(node|iojs|electron|bun)(\.exe)?$/

This works and $0 now correctly reflects the script being executed. I would propose that a single line in yargs-factory.js be changed to the following so that index.cjs is updated with the new check:

if (/\b(node|iojs|electron|bun)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {

@shadowspawn
Copy link
Member

I have not tested it, but the change is consistent with the existing code. 👍

if (/\b(node|iojs|electron)(\.exe)?$/.test(this.#shim.process.argv()[0])) {

@bcoe
Copy link
Member

bcoe commented Jan 3, 2024

_@Whobeu drive by comment 😛 _

Create a patch and we can land.

@joejordan
Copy link

Was disappointed when my yargs cli didn't work under a new Bun project. +1 for Bun support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants