Skip to content

Add --duplicates to report keys assigned more than once - #4

Merged
Gulliby merged 1 commit into
mainfrom
feature/duplicate-keys
Oct 15, 2026
Merged

Gulliby merged 1 commit into
mainfrom
feature/duplicate-keys

Conversation

@Gulliby

@Gulliby Gulliby commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Requested by gulliby

Before

A key assigned twice in .env silently uses the last value, and envguard did not report it.

After

envguard --duplicates also lists keys that .env assigns more than once. They are warnings (errors with --strict); the template file is not checked. Without the option nothing changes.

With .env.example A= and .env A=1, B=2, A=3:

$ envguard --duplicates
Success: required environment keys are present and non-empty.
Extra keys (warnings): B
Duplicate keys (warnings): A

It exits 0; with --strict the exit code is 1. --json adds a last "duplicate" field and --github adds one annotation per key.

How

  • src/parse.ts: new findDuplicateKeys, sharing the assignment parsing with parseEnv.
  • src/format.ts: optional duplicate in createReport and Report, and the human and GitHub output.
  • src/cli.ts: the --duplicates option and help line.
  • README.md: options row and a "Duplicate keys" section.
  • tests/duplicates.test.ts: 18 new tests; existing tests are unchanged.

@Gulliby
Gulliby merged commit 482ed73 into main Oct 15, 2026
6 checks passed
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.

1 participant