Skip to content

Read the config file --config names - #19

Merged
cjbarth merged 1 commit into
masterfrom
fix-config-option-ignored
Sep 17, 2026
Merged

cjbarth merged 1 commit into
masterfrom
fix-config-option-ignored

Conversation

@cjbarth

@cjbarth cjbarth commented Sep 17, 2026

Copy link
Copy Markdown
Owner

The bug

Program read the parsed option off the Commander command object:

getGrenConfig(props.cwd, program.config),

Commander has kept parsed options on opts() since v7, and this project is on v15. The
property is simply undefined, with no error and no warning, so --config and -c were
ignored and the run used whichever .grenrc* the directory happened to hold.

The failure is quiet in the worst way: gren prints the filename it loaded, so a run with
-c my-config.cjs reports Getting gren config from local file .../.grenrc.cjs and
carries on building a changelog from a configuration the user did not ask for.

The fix

Read the options from this.program.opts(), once, and use them for both the config
filename and the option merge.

A --config naming a file that is not there now stops the run. That has always been
getConfigFromFile's behaviour; nothing could reach it before.

Verification

Four tests, added first; three of them failed for the reported reason before the fix (the
fallback case passed, since falling back was all it ever did).

Run over this repository, generating to a scratch file with -c .grenrc-custom.cjs, where
the custom config sets a distinctive template.changelogTitle:

--- master: loaded .grenrc.cjs ---
# Changelog

## v5.1.1 (2026-09-16)

--- this branch: loaded .grenrc-custom.cjs ---
# Changelog

> Loaded from the config --config named.

npm test 135 passing; env -u GREN_GITHUB_TOKEN npx mocha 96 passing, 39 pending;
npm run lint clean apart from the pre-existing mocha/no-pending-tests warning in
test/Gren.spec.js. No change to lib/_options.js, so the README tables are unaffected.

🤖 Generated with Claude Code

Program read the option off the Commander command rather than opts(),
where Commander has kept parsed options since v7. The property is simply
undefined, with no error, so --config and -c were ignored and the run
used whichever .grenrc the directory happened to hold -- reporting that
filename on stdout while the user believed another file was in effect.

A missing custom config still stops the run, which is the behaviour
getConfigFromFile always had and nothing could reach.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cjbarth
cjbarth merged commit af081de into master Sep 17, 2026
2 checks passed
@cjbarth
cjbarth deleted the fix-config-option-ignored branch September 17, 2026 15:52
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