{"id":21162707,"url":"https://github.com/tmcdos/custompatch","last_synced_at":"2025-07-09T15:34:49.178Z","repository":{"id":180183986,"uuid":"158437417","full_name":"tmcdos/custompatch","owner":"tmcdos","description":"Tool for patching buggy NPM packages without forking them","archived":false,"fork":false,"pushed_at":"2025-02-12T12:15:28.000Z","size":66,"stargazers_count":26,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-27T17:16:34.280Z","etag":null,"topics":["buggy","npm-package","patching"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmcdos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-20T18:58:51.000Z","updated_at":"2025-02-26T22:07:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"61e98924-0df9-4b58-be38-df77843c0fd5","html_url":"https://github.com/tmcdos/custompatch","commit_stats":null,"previous_names":["tmcdos/custompatch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tmcdos/custompatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmcdos%2Fcustompatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmcdos%2Fcustompatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmcdos%2Fcustompatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmcdos%2Fcustompatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmcdos","download_url":"https://codeload.github.com/tmcdos/custompatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmcdos%2Fcustompatch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262978852,"owners_count":23394026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buggy","npm-package","patching"],"created_at":"2024-11-20T13:32:55.297Z","updated_at":"2025-07-09T15:34:49.125Z","avatar_url":"https://github.com/tmcdos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CustomPatch\r\n\r\nPatch a buggy NPM package without forking it.\r\n\r\nBased on the handy [diff](https://github.com/kpdecker/jsdiff) package (there is a `jsdiff` published on the NPM registry but it is a bogus one)\r\n\r\n## WHY\r\n\r\nThis tool does what [patch-package](https://www.npmjs.com/package/patch-package) does (or more accurately - should be doing) but without the related issues:\r\n\r\n- it works faster, especially when creating the patch\r\n- it never chokes on its own patches\r\n- it does not break if you try to apply a patch more than once (but shows a warning)\r\n- it does not require/depend on GIT\r\n- it does not require a lockfile present when creating patches\r\n \r\nWhen you have made a bugfix for one of your dependencies but the author/maintainers refuse to accept your PR - you do not need to fork the package.  \r\nCreate a patch and seamlessly apply it locally for all your builds.\r\n\r\n## Installation\r\n```bash\r\nnpm install custompatch -g\r\n```\r\n\r\n## Setup\r\n\r\nIt operates in exactly the same way as [patch-package](https://www.npmjs.com/package/patch-package) so you can use the same setup if you have it already.\r\nAdd the following to your `package.json`\r\n\r\n```json\r\n\"scripts\": \r\n{\r\n  \"prepare\": \"custompatch\"\r\n}\r\n```\r\n\r\n## Usage\r\n\r\n### Making patches\r\n\r\nOpen your IDE and make the required changes for the bugfix inside your dependency in `node_modules`. After that run\r\n\r\n```bash\r\ncustompatch \"name-of-the-buggy-package\"\r\n```\r\n\r\nThis will create a folder called `patches` inside your project and a file called `name-of-the-buggy-package#version.patch` in this folder.  \r\nThis file will be a unified diff between your fixed version of the dependency and its original code.\r\n\r\nYou can specify more than 1 package on the command-line - but no command-line options are accepted.\r\n\r\n### Updating patches\r\n\r\nThe process is exactly the same as for creating a patch for the first time.\r\n\r\n### Applying patches\r\n\r\nRun `custompatch` without arguments inside your project folder - it will apply all the patches from `patches` folder.  \r\nIf you want to target specific patches you can use the `--patch (-p)` flag like so:\r\n\r\n```bash\r\ncustompatch --patch [name-of-the-buggy-package]\r\n```\r\n\r\n### Reversing patches\r\n\r\nTo reverse all patches you can use the `--reverse (-r)` flag like so:\r\n\r\n```bash\r\ncustompatch --reverse\r\n```\r\n\r\nTo reverse specific patches you can use the `--reverse (-r)` flag like so:\r\n\r\n```bash\r\ncustompatch --reverse [name-of-the-buggy-package]\r\n```\r\n\r\n## Benefits of patching over forking\r\n\r\n- Forks often require extra build steps - and even more often you do not need this overhead\r\n- CustomPatch warns you when a patch was not applied cleanly - so that you can check that your fix is still valid for the new version of dependency\r\n- Keep your patches colocated with the code that depends on them\r\n- Patches can be reviewed as part of your normal review process, forks probably can't\r\n\r\n## Patch filenames format\r\n\r\nThe filename of a patch will be composed as `packageName`, followed by the `#` symbol, followed by `packageSemVer` (and the extension is `.patch`)  \r\nIf the `packageName` contains a symbol which collides with the directory separator of the current filesystem - these symbols will be replaced with `+`\r\n\r\n## License\r\n\r\nSoftware License Agreement (BSD License)\r\n\r\nCopyright (c) 2018, TMCDOS\r\n\r\nAll rights reserved.\r\n\r\nRedistribution and use of this software in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n* Redistributions of source code must retain the above\r\n  copyright notice, this list of conditions and the\r\n  following disclaimer.\r\n\r\n* Redistributions in binary form must reproduce the above\r\n  copyright notice, this list of conditions and the\r\n  following disclaimer in the documentation and/or other\r\n  materials provided with the distribution.\r\n\r\n* Neither the name of TMCDOS nor the names of its\r\n  contributors may be used to endorse or promote products\r\n  derived from this software without specific prior\r\n  written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r\nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER\r\nIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\r\nOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmcdos%2Fcustompatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmcdos%2Fcustompatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmcdos%2Fcustompatch/lists"}