LinuxCommandLibrary

bun-patch

Apply patches to dependencies

TLDR

Prepare a package for patching

$ bun patch [package]
copy

Prepare a specific version of a package
$ bun patch [package]@[version]
copy

Prepare a package located at a specific path
$ bun patch [path/to/package]
copy

Generate a patch file for changes made to a package
$ bun patch --commit [path/to/package]
copy

Generate a patch file and store it in a custom directory
$ bun patch --commit [path/to/package] --patches-dir [path/to/directory]
copy

SYNOPSIS

bun patch <package-name> [options]
bun pm patch <package-name> [options]

PARAMETERS


    The name of the dependency package to create a patch for (e.g., react, lodash).

--edit
    Opens the patched package in your default editor for modification. This is the default behavior.

--create-patch
    Creates a patch file from the current working directory, typically after manual modifications.

--keep-tree
    Prevents the deletion of the temporary directory where the package source is extracted for patching.

--output <path>
    Specifies the output path for the generated patch file.

--browser
    Attempts to open the generated patch in a browser, typically for review.

DESCRIPTION

The term "bun-patch" is not a standard, standalone Linux command. Instead, it most likely refers to the patching capabilities provided by the bun JavaScript runtime, specifically the bun patch (or bun pm patch) command. This functionality allows developers to create and apply modifications to their project's dependencies without directly forking them or waiting for upstream fixes.

It's an essential tool for situations where a quick bug fix, a temporary feature, or a test change is needed in a dependency. bun patch streamlines the process of generating standard .patch files after modifying a package's source code, which can then be consistently applied across different development environments during bun install. This helps maintain project stability and allows for rapid iteration on third-party code.

CAVEATS

The term "bun-patch" is not a standalone executable. The provided information pertains to the bun patch command within the bun JavaScript runtime. This command requires bun to be installed and is primarily relevant for JavaScript/TypeScript projects. Patches can be fragile and may require updates if the underlying dependency changes significantly.

NOT A STANDARD LINUX COMMAND

It is crucial to understand that 'bun-patch' is not a standard, standalone executable found in most Linux distributions' /usr/bin or similar paths. It is a conceptual term or a user's shorthand referring to the patching capabilities of the bun JavaScript runtime, specifically accessed via bun patch or bun pm patch.

PATCHING WORKFLOW

The typical workflow involves first running bun patch <package-name> to generate a patch. This command will usually open the package's code in your editor for modifications. Once you save your changes and close the editor, bun will automatically create a .patch file in a dedicated directory (e.g., .bun/patches/). Subsequent bun install commands will then detect and apply these generated patches, ensuring your modified dependency is used in the project.

HISTORY

The bun runtime, including its package manager features like the patch command, was developed by Jarred Sumner and publicly released in 2022. It was designed to be a fast, all-in-one JavaScript toolkit. The inclusion of a dedicated patch command addresses a long-standing need in the JavaScript ecosystem for managing temporary fixes and custom modifications to third-party dependencies, offering a more integrated solution than external tools like patch-package.

SEE ALSO

bun(1), patch(1), diff(1), npm(1), yarn(1)

Copied to clipboard