support .config directory

This commit is contained in:
silverwind 2024-03-09 02:52:24 +01:00
parent 7ea27c7a14
commit cd48e520b4
Signed by untrusted user: silverwind
GPG Key ID: 2E62B41C93869443
2 changed files with 17 additions and 7 deletions

@ -32,7 +32,7 @@ All `pkg` options support glob matching via [picomatch](https://github.com/micro
## Config File
Put a `updates.config.js` or `updates.config.mjs` in the root of your project, usually besides `package.json` to configure certain options of the module. CLI arguments have precedence over options in the config file, except for `include` and `exclude` options which are merged.
The config file is used to configure certain options of the module. CLI arguments have precedence over options in the config file, except for `include` and `exclude` options which are merged.
```js
export default {
@ -44,6 +44,15 @@ export default {
};
```
### Config File Locations
The config file can be placed in these locations, relative to `package.json` is:
- `updates.config.js`
- `updates.config.mjs`
- `.config/updates.js`
- `.config/updates.mjs`
### Config File Options
- `include` *Array[String|Regexp]*: Array of dependencies to include

@ -776,12 +776,13 @@ async function main() {
let config = {};
try {
config = (await import(join(projectDir, "updates.config.js"))).default;
} catch {
try {
config = (await import(join(projectDir, "updates.config.mjs"))).default;
} catch {}
}
({default: config} = await Promise.any([
"updates.config.js",
"updates.config.mjs",
".config/updates.js",
".config/updates.mjs",
].map(str => import(join(projectDir, ...str.split("/"))))));
} catch {}
let includeCli, excludeCli;
if (args.include && args.include !== true) { // cli