yargs / yargs/yargs

--no-config does not stop config file from being loaded

Open
#1,676 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
JavaScript
Stars
11.5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

I've got the following:

const argv = yargs.options({
  config: {
    string: true,
    config: true,
    default: 'mypackagerc'
  },
  myValue: { string: true }
});

This is working well, except that if I do --no-config, the config is still loaded if a file matching the default value exists.
It seems that config might be handled before the --no, as config is set to a value of false but properties from the mypackagerc are still loaded in.

configParser is also not passed the false value, so I can't detect it that way.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the yargs option-parsing path and the configParser entry point described in the report. Reproduce the snippet with --no-config and a present mypackagerc file; done means the file is not loaded and its properties are not added when the option is false.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.