Files
bun.sh/docs/cli/run-script.md
2024-10-08 20:23:56 -07:00

967 B

The bun CLI can be used to execute package.json scripts and much more.

The CLI options for this subcommand is identical to bun run but is specifically catered to running package.json scripts.

This specificity may be useful since if used in a directory with a file or folder that shares a name with a package.json script, then bun run will prefer attempting to load the path instead and not run the script.

Example

$ bun [bun flags] run-script <script> [script flags]

Your package.json can define a number of named "scripts" that correspond to shell commands.

{
  // ... other fields
  "scripts": {
    "clean": "rm -rf dist && echo 'Done.'",
    "dev": "bun server.ts"
  }
}

Use bun run-script <script> to execute these scripts.

$ bun run-script clean
 $ rm -rf dist && echo 'Done.'
 Cleaning...
 Done.

See Also