mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: improve config error message (#264)
This commit is contained in:
parent
fcd9ffd34d
commit
23c23156e6
@ -396,11 +396,18 @@ export class BaseClient {
|
|||||||
>() {
|
>() {
|
||||||
const seyfertConfig = (BaseClient._seyfertCfWorkerConfig ||
|
const seyfertConfig = (BaseClient._seyfertCfWorkerConfig ||
|
||||||
(await this.options?.getRC?.()) ||
|
(await this.options?.getRC?.()) ||
|
||||||
(await Promise.any(
|
(
|
||||||
|
await Promise.any(
|
||||||
['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext =>
|
['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext =>
|
||||||
magicImport(join(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x),
|
magicImport(join(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x),
|
||||||
),
|
),
|
||||||
))) as T;
|
)
|
||||||
|
).catch((e: AggregateError) => {
|
||||||
|
if (e.errors.every((err: Error) => err.stack?.includes('ERR_MODULE_NOT_FOUND'))) {
|
||||||
|
throw new Error('No seyfert.config file found');
|
||||||
|
}
|
||||||
|
throw e.errors.find((err: Error) => !err.stack?.includes('ERR_MODULE_NOT_FOUND')) ?? e.errors[0];
|
||||||
|
})) as T;
|
||||||
|
|
||||||
const { locations, debug, ...env } = seyfertConfig;
|
const { locations, debug, ...env } = seyfertConfig;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user