View Source Bun (bun v2.0.0)
Bun is an installer and runner for bun.
Profiles
You can define multiple bun profiles. By default, there is a
profile called :default which you can configure its args, current
directory and environment:
config :bun,
version: "1.3.0",
default: [
args: ~w(build js/app.js --outdir=../priv/static/assets),
cd: Path.expand("../assets", __DIR__),
env: %{}
]Bun configuration
There are two global configurations for the bun application:
:version- the expected bun version:cacerts_path- the directory to find certificates for https connections:path- the path to find the bun executable at. By default, it is automatically downloaded and placed inside the_builddirectory of your current app
Overriding the :path is not recommended, as we will automatically
download and manage bun for you. But in case you can't download
it (for example, the npm registry is behind a proxy), you may want to
set the :path to a configurable system location.
Once you find the location of the executable, you can store it in a
MIX_BUN_PATH environment variable, which you can then read in
your configuration file:
config :bun, path: System.get_env("MIX_BUN_PATH")
Summary
Functions
Returns the path to the executable.
Returns the version of the bun executable.
Calls a JavaScript module with the given arguments using the worker pool.
Calls a JavaScript module and raises on error.
Returns the configuration for the given profile.
Returns the configured bun version.
Installs, if not available, and then runs bun.
Runs the given command with args.
Starts a pool of bun workers for executing JavaScript modules.
Stops the bun worker pool.
Functions
Returns the path to the executable.
The executable may not be available if it was not yet installed.
Returns the version of the bun executable.
Returns {:ok, version_string} on success or :error when the executable
is not available.
Calls a JavaScript module with the given arguments using the worker pool.
See Bun.Supervisor.call/3 for details on arguments and options.
Example
{:ok, result} = Bun.call("myModule.js", ["arg1", "arg2"])
{:ok, result} = Bun.call("myModule.js", [], timeout: 10_000)
Calls a JavaScript module and raises on error.
See Bun.Supervisor.call!/3 for details on arguments and options.
Example
result = Bun.call!("myModule.js", ["arg1"])
Returns the configuration for the given profile.
Returns nil if the profile does not exist.
Returns the configured bun version.
Installs, if not available, and then runs bun.
Returns the same as run/2.
Runs the given command with args.
The given args will be appended to the configured args. The task output will be streamed directly to stdio. It returns the status of the underlying call.
Starts a pool of bun workers for executing JavaScript modules.
See Bun.Supervisor.start_link/1 for available options.
Example
{:ok, _pid} = Bun.start_link()
{:ok, result} = Bun.call("myModule.js", ["arg1", "arg2"])
Stops the bun worker pool.
See Bun.Supervisor.stop/1 for details.