Skip to content

Commit

Permalink
feat: support in npm_translate_lock patch_args dict (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Dec 15, 2022
1 parent b15abd3 commit ceade5f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ npm_translate_lock(
},
npmrc = "//:.npmrc",
patch_args = {
"@gregmagolan/test-a": ["-p1"],
"*": ["-p1"],
"@gregmagolan/test-a": ["-p4"],
},
patches = {
"@gregmagolan/test-a": ["//examples/npm_deps:patches/test-a.patch"],
"@gregmagolan/[email protected]": ["//examples/npm_deps:patches/[email protected]"],
"@gregmagolan/test-b": ["//examples/npm_deps:patches/test-b.patch"],
},
pnpm_lock = "//:pnpm-lock.yaml",
pnpm_version = "7.17.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/npm_deps/patches/test-a.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- a/main.js
+++ b/main.js
--- a/node_modules/@gregmagolan/test-a/main.js
+++ b/node_modules/@gregmagolan/test-a/main.js
@@ -1 +1,2 @@
module.exports = 'test-a-0.0.1';
+console.log("Hello world!")
4 changes: 2 additions & 2 deletions examples/npm_deps/patches/[email protected]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- a/main.js
+++ b/main.js
--- a/node_modules/@gregmagolan/test-a/main.js
+++ b/node_modules/@gregmagolan/test-a/main.js
@@ -1,2 +1,3 @@
module.exports = 'test-a-0.0.1';
console.log("Hello world!")
Expand Down
5 changes: 5 additions & 0 deletions examples/npm_deps/patches/test-b.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--- a/main.js
+++ b/main.js
@@ -1 +1,2 @@
module.exports = 'test-b-0.0.1';
+console.log("Hello world!")
2 changes: 1 addition & 1 deletion npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def _gen_npm_imports(importers, packages, root_package, attr, registries, defaul

# gather patches & patch args
patches = _gather_values_from_matching_names(True, attr.patches, name, friendly_name, unfriendly_name)
patch_args = _gather_values_from_matching_names(False, attr.patch_args, name, friendly_name, unfriendly_name)
patch_args = _gather_values_from_matching_names(False, attr.patch_args, "*", name, friendly_name, unfriendly_name)

# gather custom postinstalls
custom_postinstalls = _gather_values_from_matching_names(True, attr.custom_postinstalls, name, friendly_name, unfriendly_name)
Expand Down
4 changes: 3 additions & 1 deletion npm/private/test/repositories_checked.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ def npm_repositories():
"@gregmagolan/test-a": ["0.0.1"],
},
patches = ["//examples/npm_deps:patches/test-a.patch", "//examples/npm_deps:patches/[email protected]"],
patch_args = ["-p1"],
patch_args = ["-p4"],
)

npm_import(
Expand All @@ -1239,6 +1239,8 @@ def npm_repositories():
"@gregmagolan/test-b": ["0.0.2"],
"@gregmagolan/test-a": ["0.0.1"],
},
patches = ["//examples/npm_deps:patches/test-b.patch"],
patch_args = ["-p1"],
)

npm_import(
Expand Down

0 comments on commit ceade5f

Please sign in to comment.