Skip to content

Fix: respect pre-existing env vars over .mappsrc config file#156

Open
codyfrisch wants to merge 1 commit intomondaycom:masterfrom
codyfrisch:fix/env-var-precedence
Open

Fix: respect pre-existing env vars over .mappsrc config file#156
codyfrisch wants to merge 1 commit intomondaycom:masterfrom
codyfrisch:fix/env-var-precedence

Conversation

@codyfrisch
Copy link
Copy Markdown

Summary

  • Fixes .mappsrc config file unconditionally overwriting pre-existing environment variables
  • Adds force parameter to setConfigDataInProcessEnv — defaults to false so the init hook respects env vars already set by the user
  • mapps init passes force: true so explicitly entered tokens always take effect

Closes #155

Motivation

When working on the same project with multiple accounts (e.g. dev vs test/prod), there's no way to temporarily override the stored token via MONDAY_CODE_ACCESS_TOKEN without re-running mapps init. The --local flag solves per-project config but not per-account switching.

Standard CLI convention is: env var > config file > default. This change aligns mapps with that expectation.

Changes

  • src/services/config-service.ts: setConfigDataInProcessEnv now checks if the env var is already set before writing (unless force: true)
  • src/services/__tests__/config-service.test.ts: New test suite covering the precedence behavior and the init force-set edge case

Test plan

  • Existing tests pass (12 suites, 46 tests)
  • New tests verify: file values load into env, pre-existing env vars are not overwritten, mapps init force-sets even with pre-existing env var
  • Manual: set MONDAY_CODE_ACCESS_TOKEN before running an authenticated command with a .mappsrc present — env var takes precedence as expected

🤖 Generated with Claude Code

setConfigDataInProcessEnv now skips env vars that are already set,
unless force=true (used by mapps init when the user explicitly
provides a new token).

Closes mondaycom#155

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.mappsrc config file overwrites pre-existing environment variables

1 participant