UNPKG

1.42 kBTypeScriptView Raw
1import * as glob from '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 * Metadata of the module as well as the loaded module itself.
24 */
25export interface LoadedModuleDescriptor extends ModuleDescriptor {
26 value: unknown;
27}
28/**
29 * A glob pattern with associated registration options.
30 */
31export declare type GlobWithOptions = [string] | [string, BuildResolverOptions<any> | LifetimeType];
32/**
33 * Returns a list of {name, path} pairs,
34 * where the name is the module name, and path is the actual
35 * full path to the module.
36 *
37 * @param {String|Array<String>} globPatterns
38 * The glob pattern as a string or an array of strings.
39 *
40 * @param {String} opts.cwd
41 * Current working directory, used for resolving filepaths.
42 * Defaults to `process.cwd()`.
43 *
44 * @return {[{name, path}]}
45 * An array of objects with the module names and paths.
46 */
47export declare function listModules(globPatterns: string | Array<string | GlobWithOptions>, opts?: ListModulesOptions): ModuleDescriptor[];