Skip to content

Commit

Permalink
build: add 'override_env' dict option to dev_pnpm_task_binary
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Jan 8, 2024
1 parent 7253750 commit 55d67d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/api/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ dev_pnpm_task_binary(
srcs = [":src"],
visibility = ["PUBLIC"],
env = dummy_env_dict,
override_env = {
"MONGODB_CON": "mongodb://localhost:27017/galoy",
},
)

dev_pnpm_task_binary(
Expand Down
11 changes: 10 additions & 1 deletion toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ def dict_to_env_string(input_dict):
return '\n'.join(env_strings)

def pnpm_task_binary_impl(ctx: AnalysisContext) -> list[[DefaultInfo, RunInfo]]:
env_file = ctx.actions.write(".env", dict_to_env_string(ctx.attrs.env), is_executable = True)
combined_env = dict(ctx.attrs.env)
combined_env.update(ctx.attrs.override_env)
env_file = ctx.actions.write(".env", dict_to_env_string(combined_env), is_executable = True)

script = ctx.actions.write("pnpm-run.sh", """\
#!/usr/bin/env bash
Expand Down Expand Up @@ -1092,6 +1094,13 @@ dev_pnpm_task_binary = rule(impl = pnpm_task_binary_impl, attrs = {
default = {},
doc = """Env values to inject for pnpm command run"""
),
"override_env": attrs.dict(
key = attrs.string(),
value = attrs.arg(),
sorted = False,
default = {},
doc = """Env values to override originally injected values with"""
),
})

def pnpm_task_test_impl(ctx: AnalysisContext) -> list[[DefaultInfo, ExternalRunnerTestInfo]]:
Expand Down

0 comments on commit 55d67d1

Please sign in to comment.