From a965fb906fb7710d0b150a72928040f99552c9ed Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 10 Aug 2024 14:05:55 +0200 Subject: [PATCH] refactor loadConfig --- index.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/index.ts b/index.ts index fa58147..5ee359f 100755 --- a/index.ts +++ b/index.ts @@ -883,18 +883,17 @@ function resolveFiles(filesArg: Set): [Set, Set] { } async function loadConfig(rootDir: string): Promise { + const filenames: string[] = []; + for (const prefix of ["", ".config/"]) { + for (const ext of ["js", "ts", "mjs", "mts"]) { + filenames.push(`${prefix}updates${prefix ? "" : ".config"}.${ext}`); + } + } let config: Config = {}; try { - ({default: config} = await Promise.any([ - "updates.config.js", - "updates.config.ts", - "updates.config.mjs", - "updates.config.mts", - ".config/updates.js", - ".config/updates.ts", - ".config/updates.mjs", - ".config/updates.mts", - ].map(str => import(join(rootDir, ...str.split("/")))))); + ({default: config} = await Promise.any(filenames.map(str => { + return import(join(rootDir, ...str.split("/"))); + }))); } catch {} return config; }