Warn when `NI_CONFIG_FILE` points to a missing file
Description
When NI_CONFIG_FILE points to a file that does not exist, it is ignored without any message:
https://github.com/antfu-collective/ni/blob/2d8c88e9f0d302da75eda36e1a158141714a351e/src/config.ts#L8-L16 https://github.com/antfu-collective/ni/blob/2d8c88e9f0d302da75eda36e1a158141714a351e/src/config.ts#L98
config = { ...defaultConfig, ...fs.existsSync(rcPath) ? readRcFile(rcPath) : null }A typo in the path, or a relative path, silently leaves ni on the built-in defaults, and nothing explains why the configuration has no effect. With #363, setting NI_CONFIG_FILE also turns off .nirc discovery, so a wrong path would disable every config file at once.
Relative paths
A relative NI_CONFIG_FILE is resolved against process.cwd(), not against the -C <dir> target. That seems correct, since it is the usual meaning of a relative path in an environment variable and every README example uses an absolute path, but it is worth documenting, because ni -C packages/app with NI_CONFIG_FILE=.nirc does not read packages/app/.nirc.
Proposal
- Warn when
NI_CONFIG_FILEis set but the file does not exist, in the same style as the warnings for unreadable.nircfiles (#364):[ni] NI_CONFIG_FILE points to /path/to/nirc, which does not exist - Note in the README that a relative path is resolved against the current working directory.
vitest.config.ts sets NI_CONFIG_FILE=false to keep the developer's own config out of the tests, so the suite would need another way to opt out, for example pointing it at an empty file in the fixtures.
Source: antfu-collective/ni