Skip to main content

abstractConfiguration <T>

Hierarchy

  • Contract<T>
    • Configuration

Index

Events

readonlyonLoadedConfig

onLoadedConfig: WaterfallEvent<ConfigFile<T>[], string> = ...

Called after config files are loaded but before processed. Can modify config file list.

readonlyonLoadedIgnore

onLoadedIgnore: WaterfallEvent<IgnoreFile[], string> = ...

Called after ignore files are loaded. Can modify ignore file list.

readonlyonProcessedConfig

onProcessedConfig: Event<[Required<T>], string> = ...

Called after config files are loaded and processed.

Other

constructor

  • new Configuration<T>(name: string, resolver?: ModuleResolver): Configuration<T>
  • Type parameters

    • T: object

readonlyoptions

options: Readonly<Required<T>>

Validated and configured options.

publicaddProcessHandler

  • addProcessHandler<K, V>(key: K, handler: Handler<V>): this
  • Add a process handler to customize the processing of key-value setting pairs. May only run a processor on settings found in the root of the configuration object.


    Type parameters

    • K: string | number | symbol
    • V = T[K]

abstractblueprint

  • blueprint(_schemas: __module, onConstruction?: boolean): object
  • Define an optimal blueprint in which to validate and build the options object passed to the constructor, or when manual setting.

    A boolean is passed as the 2nd argument to determine whether this is validating on class instantiation (first time), or by calling configure() (all other times).

publicbootstrap

  • bootstrap(): void
  • Life cycle called on initialization.

clearCache

  • clearCache(): this
  • Clear all cache.

clearFileCache

  • clearFileCache(): this
  • Clear all cached file contents.

clearFinderCache

  • clearFinderCache(): this
  • Clear all cached directory and file path information.

configure

  • configure(options?: Partial<T> | (options: Required<T>) => Partial<T>): Readonly<Required<T>>
  • Set an options object by merging the new partial and existing options with the defined blueprint, while running all validation checks. Freeze and return the options object.

    object.configure({ name: 'Boost' });

    object.configure((prevOptions) => ({
    nestedObject: {
    ...prevOptions.nestedObject,
    some: 'value',
    },
    }));

publicconfigureFinder

  • Configure the finder instance.

publicconfigureProcessor

  • Configure the processor instance.

findRootDir

  • findRootDir(fromDir?: PortablePath): Promise<Path>
  • Attempt to find the root directory starting from the provided directory. Once the root is found, it will be cached for further lookups, otherwise an error is thrown based on current configuration.

loadConfigFromBranchToRoot

  • Traverse upwards from the branch directory, until the root directory is found, or we reach to top of the file system. While traversing, find all config files within each branch directory, and the root.

loadConfigFromRoot

  • Load config files from the defined root. Root is determined by a relative .config folder and package.json file.

loadIgnoreFromBranchToRoot

  • loadIgnoreFromBranchToRoot(dir: PortablePath): Promise<IgnoreFile[]>
  • Traverse upwards from the branch directory, until the root directory is found, or we reach to top of the file system. While traversing, find all ignore files within each branch directory, and the root.

loadIgnoreFromRoot

  • loadIgnoreFromRoot(dir?: PortablePath): Promise<IgnoreFile[]>
  • Load ignore file from the defined root. Root is determined by a relative .config folder and package.json file.

setRootDir

  • setRootDir(dir: PortablePath): this
  • Explicitly set the root directory to stop traversal at. This should only be set manually when you want full control, and know file boundaries up front.

    This does not check for the existence of the root config file or folder.