Description
I see there’s already an issue about using a .env file for local config, and a PR that renames it to .opencommit.env.
However, this naming does not follow common Node.js config file conventions.
Examples of standard config file names:
- ESLint:
.eslintrc / eslint.config.js
- Prettier:
.prettierrc
- Stylelint:
.stylelintrc
- Jest:
jest.config.js
Suggested Solution
Use a config loader like cosmiconfig, which supports popular formats like .opencommitrc, opencommit.config.js, etc.
By default, Cosmiconfig will check the current directory for the following:
- a
package.json property
- a JSON or YAML, extensionless "rc file"
- an "rc file" with the extensions
.json, .yaml, .yml, .js, .ts, .mjs, or .cjs
- any of the above two inside a
.config subdirectory
- a
.config.js, .config.ts, .config.mjs, or .config.cjs file
This would:
- Follow standard naming
- Simplify config handling (loading, merging configs, etc.)
- Allow removal of custom logic:
|
export const getConfig = ({ |
|
envPath = defaultEnvPath, |
|
globalPath = defaultConfigPath |
|
}: GetConfigOptions = {}): ConfigType => { |
|
const envConfig = getEnvConfig(envPath); |
|
const globalConfig = getGlobalConfig(globalPath); |
|
|
|
const config = mergeConfigs(envConfig, globalConfig); |
|
|
|
const cleanConfig = cleanUndefinedValues(config); |
|
|
|
return cleanConfig as ConfigType; |
|
}; |
Happy to help if needed!
Alternatives
No response
Additional Context
No response
Description
I see there’s already an issue about using a
.envfile for local config, and a PR that renames it to.opencommit.env.However, this naming does not follow common Node.js config file conventions.
Examples of standard config file names:
.eslintrc/eslint.config.js.prettierrc.stylelintrcjest.config.jsSuggested Solution
Use a config loader like cosmiconfig, which supports popular formats like
.opencommitrc,opencommit.config.js, etc.This would:
opencommit/src/commands/config.ts
Lines 919 to 931 in c1756b8
Happy to help if needed!
Alternatives
No response
Additional Context
No response