mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 06:26:26 +00:00
feat(config): add .cjs
file extension config support (#26075)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
181c52f1d7
commit
178cc71838
4 changed files with 8 additions and 0 deletions
|
@ -24,6 +24,9 @@ If you need an alternate location or name, set it in the environment variable `R
|
||||||
For example `RENOVATE_CONFIG_FILE=myconfig.js` or `RENOVATE_CONFIG_FILE=myconfig.json` and not `RENOVATE_CONFIG_FILE=myconfig`.
|
For example `RENOVATE_CONFIG_FILE=myconfig.js` or `RENOVATE_CONFIG_FILE=myconfig.json` and not `RENOVATE_CONFIG_FILE=myconfig`.
|
||||||
If none is provided, or the file type is invalid, Renovate will fail.
|
If none is provided, or the file type is invalid, Renovate will fail.
|
||||||
|
|
||||||
|
If you are in an ESM repo (`"type": "module"` in `package.json`) then you must use a `.cjs` extension and set `RENOVATE_CONFIG_FILE`.
|
||||||
|
For example `RENOVATE_CONFIG_FILE=myconfig.cjs`.
|
||||||
|
|
||||||
Using a configuration file gives you very granular configuration options.
|
Using a configuration file gives you very granular configuration options.
|
||||||
For instance, you can override most settings at the global (file), repository, or package level.
|
For instance, you can override most settings at the global (file), repository, or package level.
|
||||||
e.g. apply one set of labels for `backend/package.json` and a different set of labels for `frontend/package.json` in the same repository.
|
e.g. apply one set of labels for `backend/package.json` and a different set of labels for `frontend/package.json` in the same repository.
|
||||||
|
|
3
lib/workers/global/config/parse/__fixtures__/config.cjs
Normal file
3
lib/workers/global/config/parse/__fixtures__/config.cjs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
token: 'abcdefg',
|
||||||
|
};
|
|
@ -24,6 +24,7 @@ describe('workers/global/config/parse/file', () => {
|
||||||
describe('.getConfig()', () => {
|
describe('.getConfig()', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['custom js config file', 'config.js'],
|
['custom js config file', 'config.js'],
|
||||||
|
['custom js config file', 'config.cjs'],
|
||||||
['custom js config file exporting a Promise', 'config-promise.js'],
|
['custom js config file exporting a Promise', 'config-promise.js'],
|
||||||
['custom js config file exporting a function', 'config-function.js'],
|
['custom js config file exporting a function', 'config-function.js'],
|
||||||
// The next two are different syntactic ways of expressing the same thing
|
// The next two are different syntactic ways of expressing the same thing
|
||||||
|
|
|
@ -25,6 +25,7 @@ export async function getParsedContent(file: string): Promise<RenovateConfig> {
|
||||||
await readSystemFile(file, 'utf8'),
|
await readSystemFile(file, 'utf8'),
|
||||||
file,
|
file,
|
||||||
) as RenovateConfig;
|
) as RenovateConfig;
|
||||||
|
case '.cjs':
|
||||||
case '.js': {
|
case '.js': {
|
||||||
const tmpConfig = await import(file);
|
const tmpConfig = await import(file);
|
||||||
let config = tmpConfig.default
|
let config = tmpConfig.default
|
||||||
|
|
Loading…
Reference in a new issue