allow looking up the exe path of a npm_bin

This commit is contained in:
Brian Hicks 2023-05-09 13:15:20 -05:00
parent 05b565096b
commit 67abb474c3
No known key found for this signature in database
GPG Key ID: C4F324B9CAAB0D50

View File

@ -56,7 +56,7 @@ node_modules = rule(
},
)
def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type, TemplatePlaceholderInfo.type]]:
bin_name = ctx.attrs.bin_name or ctx.attrs.name
out = ctx.actions.declare_output(bin_name)
@ -79,6 +79,11 @@ def _npm_bin_impl(ctx: "context") -> [[DefaultInfo.type, RunInfo.type]]:
return [
DefaultInfo(default_output = out),
RunInfo(out),
TemplatePlaceholderInfo(
keyed_variables = {
"exe": out,
},
),
]
npm_bin = rule(