Urara-Blog/node_modules/.pnpm-store/v3/files/d2/2297ff1d9c9e548a3a6c0f59eb0a85780e67871b3d48dc993f0144cf47b8843560f9106bdfe3e004d7208099bd80d623bfa930d3fd416b5a9d297cc6a333d0
2022-08-14 01:14:53 +08:00

62 lines
1.7 KiB
Text

import { Awaitable, Arrayable } from '@antfu/utils';
declare const defaultExtensions: string[];
declare type BuiltinParsers = 'require' | 'json';
declare type CustomParser<T> = (filepath: string) => Awaitable<T | undefined>;
interface LoadConfigSource<T = any> {
files: Arrayable<string>;
/**
* @default ['mts', 'cts', 'ts', 'mjs', 'cjs', 'js', 'json', '']
*/
extensions?: string[];
/**
* Loader for loading config,
*
* @default 'auto'
*/
parser?: BuiltinParsers | CustomParser<T> | 'auto';
/**
* Rewrite the config object,
* return nullish value to bypassing loading the file
*/
rewrite?: <F = any>(obj: F, filepath: string) => Promise<T | undefined> | T | undefined;
/**
* Transform the source code before loading,
* return nullish value to skip transformation
*/
transform?: (code: string, filepath: string) => Promise<string | undefined> | string | undefined;
/**
* Skip this source if error occurred on loading
*
* @default false
*/
skipOnError?: boolean;
}
interface SearchOptions {
/**
* Root directory
*
* @default process.cwd()
*/
cwd?: string;
/**
* @default path.parse(cwd).root
*/
stopAt?: string;
/**
* Load from multiple sources and merge them
*
* @default false
*/
merge?: boolean;
}
interface LoadConfigOptions<T = any> extends SearchOptions {
sources: Arrayable<LoadConfigSource<T>>;
defaults?: T;
}
interface LoadConfigResult<T> {
config: T;
sources: string[];
}
export { BuiltinParsers as B, CustomParser as C, LoadConfigOptions as L, SearchOptions as S, LoadConfigResult as a, LoadConfigSource as b, defaultExtensions as d };