From e8ba0f9cf2fa8236d97b6333f7e67ba3288c667b Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 2 Apr 2024 22:07:08 -0400 Subject: [PATCH] refactor: always set use_default_shell_env on generated lifecycle hook js_run_binary (#1581) --- npm/private/npm_import.bzl | 8 +++----- npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl | 1 + npm/private/test/snapshots/wksp/fsevents_links_defs.bzl | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index 85314734f..457b086ec 100644 --- a/npm/private/npm_import.bzl +++ b/npm/private/npm_import.bzl @@ -189,7 +189,8 @@ _LINK_JS_PACKAGE_LIFECYCLE_TMPL = """\ execution_requirements = {lifecycle_hooks_execution_requirements}, mnemonic = "NpmLifecycleHook", progress_message = "Running lifecycle hooks on npm package {package}@{version}", - env = {lifecycle_hooks_env},{maybe_use_default_shell_env} + env = {lifecycle_hooks_env}, + use_default_shell_env = {use_default_shell_env}, ) # post-lifecycle npm_package @@ -793,10 +794,7 @@ def _npm_import_links_rule_impl(rctx): virtual_store_root = utils.virtual_store_root, maybe_bins = maybe_bins, dev = rctx.attr.dev, - # Insert nothing when `lifecycle_hooks_use_default_shell_env` is None to remain backwards-compatible - # with bazel-lib `run_binary` before `use_default_shell_env` was added. - # TODO(2.0): remove support for old bazel-lib without `run_binary(use_default_shell_env)` - maybe_use_default_shell_env = "\n use_default_shell_env = True," if rctx.attr.lifecycle_hooks_use_default_shell_env else "", + use_default_shell_env = rctx.attr.lifecycle_hooks_use_default_shell_env, ) npm_link_package_bzl = [ diff --git a/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl b/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl index 014ee347e..8259aaec4 100644 --- a/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl +++ b/npm/private/test/snapshots/bzlmod/fsevents_links_defs.bzl @@ -155,6 +155,7 @@ def npm_imported_package_store(name): mnemonic = "NpmLifecycleHook", progress_message = "Running lifecycle hooks on npm package fsevents@2.3.2", env = {}, + use_default_shell_env = False, ) # post-lifecycle npm_package diff --git a/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl b/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl index 4ac7f2f1a..ca53ea6db 100644 --- a/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl +++ b/npm/private/test/snapshots/wksp/fsevents_links_defs.bzl @@ -155,6 +155,7 @@ def npm_imported_package_store(name): mnemonic = "NpmLifecycleHook", progress_message = "Running lifecycle hooks on npm package fsevents@2.3.2", env = {}, + use_default_shell_env = False, ) # post-lifecycle npm_package