Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pre and post install patches to yarn_install and npm_install #2607

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

gregmagolan
Copy link
Collaborator

For example,

yarn_install(
    name = "internal_npm_install_test_patches_yarn",
    package_json = "//internal/npm_install/test/patches_yarn:package.json",
    package_path = "internal/npm_install/test/patches_yarn",
    patch_args = ["-p0"],
    patch_tool = "patch",
    post_install_patches = ["//internal/npm_install/test/patches_yarn:semver+1.0.0.patch"],
    pre_install_patches = ["//internal/npm_install/test/patches_yarn:package_json.patch"],
    symlink_node_modules = False,
    yarn_lock = "//internal/npm_install/test/patches_yarn:yarn.lock",
)

where paths in patch files are relative to the workspace root,

package_json.patch:

--- internal/npm_install/test/patches_npm/package.json
+++ internal/npm_install/test/patches_npm/package.json
@@ -1,6 +1,5 @@
 {
   "dependencies": {
-    "__invalid_dependency__": "removed by pre_install_patches",
     "semver": "1.0.0"
   }
 }

semver+1.0.0.patch:

--- internal/npm_install/test/patches_npm/node_modules/semver/semver.js
+++ internal/npm_install/test/patches_npm/node_modules/semver/semver.js
@@ -34,6 +34,7 @@ exports.valid = valid
 exports.validPackage = validPackage
 exports.validRange = validRange
 exports.maxSatisfying = maxSatisfying
+exports.patched = true
 
 function clean (ver) {
   v = exports.parse(ver)

patch_tool and patch_args have same meaning as for other bazel repository rules such as http_archive

@alexeagle alexeagle merged commit d805f33 into bazel-contrib:stable Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants