oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.21k stars 2.77k forks source link

Be able to pipe data to `bun --print` #9438

Open mathiasrw opened 8 months ago

mathiasrw commented 8 months ago

What is the problem this feature would solve?

Keeping longer scripts (and multi line scripts) outside of package.js and other places that uses --print

What is the feature you are proposing to solve the problem?

Have bun --print use the data that is piped in as the js source if no parameter has been provided

cat '2+3' | bun --print
5

What alternatives have you considered?

If you generate the JS content you want to run you can store that in a file instead of piping it and call bun run x.js - while also adding console.log() around the last statement.

Jarred-Sumner commented 8 months ago

cool idea