pkgConf skips a directory whose name contains a dot
Author: x0LazarusCreated Sep 26, 2026Updated Sep 26, 2026
When I pass a directory such as release.v1 to .pkgConf(key, cwd), yargs skips that directory's package.json and reads the parent's configuration instead. The same setup works when the directory is named plain.
For example, with these files:
project/
package.json { "settings": { "picked": "parent" } }
release.v1/
package.json { "settings": { "picked": "child" } }Run from project:
import yargs from 'yargs';
console.log(
yargs([]).pkgConf('settings', './release.v1').parseSync().picked
);Expected: child. Actual: parent.
I reproduced this on Windows with Node 24.19.0 against main at e49b60a (18.2.0). Each case uses a fresh yargs instance, so this differs from the repeated-call problem in #2191.
The package lookup treats any path with an extension as a file and starts searching in its parent. A directory name can also have an extension. I would like to fix that distinction and add regression tests, while preserving lookup from an actual file path.
Source: yargs/yargs