diff --git a/e2e/smoke/BUILD.bazel b/e2e/smoke/BUILD.bazel index c902e09e1f..afbe9664e1 100644 --- a/e2e/smoke/BUILD.bazel +++ b/e2e/smoke/BUILD.bazel @@ -184,6 +184,14 @@ diff_test( target_compatible_with = not_windows, ) +genrule( + name = "npm_help", + outs = ["help.txt"], + cmd = "$(NPM_PATH) --help > $@ || true", + toolchains = ["@nodejs_toolchains//:resolved_toolchain"], + tools = ["@nodejs_toolchains//:resolved_toolchain"], +) + ################################################ # Tests and setup for the toolchain changes diff --git a/nodejs/toolchain.bzl b/nodejs/toolchain.bzl index 6163d10999..804f8a3c95 100644 --- a/nodejs/toolchain.bzl +++ b/nodejs/toolchain.bzl @@ -83,9 +83,10 @@ def _nodejs_toolchain_impl(ctx): "NODE_PATH": ctx.file.node.path if ctx.attr.node else ctx.attr.node_path, "NPM_PATH": ctx.file.npm.path if ctx.attr.npm else ctx.attr.npm_path, }) + files = [f for f in [ctx.file.node, ctx.file.npm] if f] default = DefaultInfo( - files = depset([ctx.file.node]) if ctx.attr.node else depset(), - runfiles = ctx.runfiles(files = [ctx.file.node] if ctx.attr.node else []), + files = depset(files), + runfiles = ctx.runfiles(files = files), ) npm_sources = depset([ctx.file.npm] + ctx.files.npm_srcs) nodeinfo = NodeInfo(