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

fix(docs): Fix the text that bun run --bun is the same as bun #4647

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

DuGlaser
Copy link
Contributor

@DuGlaser DuGlaser commented Sep 9, 2023

What does this PR do?

Hello, I've just started using bun!
I was a bit puzzled by the different behavior between bun and bun run when dealing with files that have a shebang (the documentation states that the two commands should behave identically).
When I use the --bun option, the behavior becomes the same as expected. I think this might be a better approach. What do you think? (I've just started using bun, so I could be wrong).
P.S. This message was machine-translated, so I apologize if it's hard to understand.

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

@jakeboone02
Copy link
Contributor

Per the documentation, bun and bun run are equivalent when running package.json scripts.

The --bun flag is useful for the package runner bunx. The --bun flag forces Bun to use its own runtime instead of Node when a script's shebang specifies Node (#!/usr/bin/env node). Relevant docs here: https://bun.sh/docs/cli/bunx#shebangs.

(Important note: --bun must come before the executable name.)

@DuGlaser
Copy link
Contributor Author

Yes, the documentation states that bun and bun run should behave the same. However, they behave differently when dealing with files that have a shebang.

For example, consider the following:

$ cat index.js
#!/usr/bin/env node

console.log('Hello, world!')

$ bun run index.js
error: missing script "index.js"

$ bun index.js
Hello, world!

Because of this, I thought it might be more accurate to write that bun and bun --bun run behave the same, rather than saying bun and bun run are identical.

@jakeboone02
Copy link
Contributor

Oh I see. I think this is a bug rather than a documentation issue. I filed #4850 to track.

@colinhacks colinhacks merged commit a31d69b into oven-sh:main Sep 14, 2023
@colinhacks
Copy link
Contributor

colinhacks commented Sep 14, 2023

Definitely a bug, so we'll leave the doc unchanged (more or less). I took this opportunity to improve the wording a bit.

paperdave pushed a commit to SuperAuguste/bun that referenced this pull request Sep 18, 2023
…en-sh#4647)

* fix(docs): Fix the text that `bun run --bun` is the same as `bun`

* Updates

---------

Co-authored-by: Colin McDonnell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants