Changelog
Unreleased
Added
- Marketing-style README. API reference table, 30-second tour,
EnvLoaderOptionsdocumentation, file-resolution chain, coercion table, and aCaveatssection that calls out the known sharp edges (env()collapsingnull,resetEnvnot deleting later-added keys, the quoted-value-with-trailing-comment parse bug). llms.txt/llms-full.txt. AI-discoverable index and concatenated reference, matching the@mongez/atomshape so the docs aggregator can pick them up.skills/folder. Reference cards for tool-assisted development —README,overview,loader(file resolution + options),parser(line/value coercion + interpolation),recipes.- Vitest test suite. 56 passing assertions across
parse-line,parse-value,load-env-file,load-env, andknown-bugs, covering type coercion, quoted values,#-inside-quotes,${VAR}interpolation, file resolution underNODE_ENV, shared-env layering, override semantics, default-value fallbacks,env.all(), andresetEnv. - CI workflow. GitHub Actions matrix matching the rest of the
@mongez/*family: Node 18 / 20 / 22 on Ubuntu, plus Node 20 on Windows. - Vitest config. Self-detecting sibling-alias pattern (no-op today since
@mongez/dotenvhas no@mongez/*runtime deps, but the same hook point as the other packages). package.jsonpolish. Expandeddescription, expandedkeywords,sideEffects: false,test/test:watchscripts wired to vitest.
Fixed
env(key)now preserves a deliberately-loadednull(src/index.ts:174). The implementation switched fromenvData[key] ?? defaultValuetokey in envData ? envData[key] : defaultValue, soenv("EST_TIME")returnsnullwhen.envcontainsEST_TIME=nullinstead of falling through to the default.parseValuecorrectly handles quoted values that contain#and a trailing comment (src/index.ts:55-111). The two-branch slice-then-split logic was replaced with a single quote-aware pass: detect the wrapping quote (one of",',`), find the matching closing quote vialastIndexOf, take the substring between, then unescape\<quote>sequences. Anything after the closing quote (whitespace +# comment) is discarded.loadEnvFileno longer callsparseValuetwice per line (src/index.ts:150-172).parseLinealready runsparseValueon the right-hand side, so the loop body now assigns the result directly — removing wasted work and the footgun for any future non-idempotentparseValuebranch.resetEnvnow deletes process.env keys added since module load (src/index.ts:13,src/index.ts:26-44,src/index.ts:166-170). AloadedKeys: Set<string>tracks every key written toprocess.envbyloadEnvFile. On reset, those keys are deleted fromprocess.envbefore the initial-snapshot restore step runs, so reset truly returns the process environment to t0 with respect to anything the loader added. Keys that callers set directly onprocess.env(without going throughloadEnv) are not tracked and continue to survive reset — the caller owns their own additions.
Tests
56 passed | 0 skipped