update getConfig function to accept custom config file names
Some checks failed
build / build (push) Failing after 10s
Some checks failed
build / build (push) Failing after 10s
This commit is contained in:
@@ -12,8 +12,8 @@ function getConfigDir(moduleName: string): string {
|
|||||||
return path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), moduleName);
|
return path.join(process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), ".config"), moduleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getConfig(moduleName: string): Promise<unknown> {
|
export async function getConfig(moduleName: string, configName = "config"): Promise<unknown> {
|
||||||
const configPath = path.join(getConfigDir(moduleName), "config.json");
|
const configPath = path.join(getConfigDir(moduleName), `${configName}.json`);
|
||||||
|
|
||||||
return readFile(configPath, "utf8")
|
return readFile(configPath, "utf8")
|
||||||
.then((configJson) => JSON.parse(configJson) as unknown)
|
.then((configJson) => JSON.parse(configJson) as unknown)
|
||||||
|
|||||||
Reference in New Issue
Block a user