UNPKG

1.25 kBTypeScriptView Raw
1import glob from 'fast-glob';
2import { BuildResolverOptions } from './resolvers';
3import { LifetimeType } from './awilix';
4/**
5 * The options when invoking listModules().
6 * @interface ListModulesOptions
7 */
8export interface ListModulesOptions {
9 cwd?: string;
10 glob?: typeof glob.sync;
11}
12/**
13 * An object containing the module name and path (full path to module).
14 *
15 * @interface ModuleDescriptor
16 */
17export interface ModuleDescriptor {
18 name: string;
19 path: string;
20 opts: any;
21}
22/**
23 * A glob pattern with associated registration options.
24 */
25export type GlobWithOptions = [string] | [string, BuildResolverOptions<any> | LifetimeType];
26/**
27 * Returns a list of {name, path} pairs,
28 * where the name is the module name, and path is the actual
29 * full path to the module.
30 *
31 * @param {String|Array<String>} globPatterns
32 * The glob pattern as a string or an array of strings.
33 *
34 * @param {String} opts.cwd
35 * Current working directory, used for resolving filepaths.
36 * Defaults to `process.cwd()`.
37 *
38 * @return {[{name, path}]}
39 * An array of objects with the module names and paths.
40 */
41export declare function listModules(globPatterns: string | Array<string | GlobWithOptions>, opts?: ListModulesOptions): ModuleDescriptor[];