Skip to content

Commit f422dbc

Browse files
committed
fix: expose npm binary in toolchain files
Fixes #3844
1 parent 6b76091 commit f422dbc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

e2e/smoke/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ diff_test(
184184
target_compatible_with = not_windows,
185185
)
186186

187+
genrule(
188+
name = "npm_help",
189+
outs = ["help.txt"],
190+
cmd = "$(NPM_PATH) --help > $@ || true",
191+
toolchains = ["@nodejs_toolchains//:resolved_toolchain"],
192+
tools = ["@nodejs_toolchains//:resolved_toolchain"],
193+
)
194+
187195
################################################
188196
# Tests and setup for the toolchain changes
189197

nodejs/toolchain.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ def _nodejs_toolchain_impl(ctx):
8383
"NODE_PATH": ctx.file.node.path if ctx.attr.node else ctx.attr.node_path,
8484
"NPM_PATH": ctx.file.npm.path if ctx.attr.npm else ctx.attr.npm_path,
8585
})
86+
files = [f for f in [ctx.file.node, ctx.file.npm] if f]
8687
default = DefaultInfo(
87-
files = depset([ctx.file.node]) if ctx.attr.node else depset(),
88-
runfiles = ctx.runfiles(files = [ctx.file.node] if ctx.attr.node else []),
88+
files = depset(files),
89+
runfiles = ctx.runfiles(files = files),
8990
)
9091
npm_sources = depset([ctx.file.npm] + ctx.files.npm_srcs)
9192
nodeinfo = NodeInfo(

0 commit comments

Comments
 (0)