import { Logger, WritableFileFormat, ManagerLoadOptions, ManagerFromDataOptions } from "./types"; import DataFile from "./data-file"; /** * Manage multiple configuration files using [[DataFile]]. */ export default class Manager { #private; /** * Creates a manager to manage multiple data files. * * @param root is the root path to be used for all relative file paths. * @param logger is the winston compatible Logger to be used when logging. * @param saveIfChanged is whether to save file only if data is changed. Clones initial data deeply to check during save. */ constructor({ root, logger, saveIfChanged }?: { root?: string; logger?: Logger; saveIfChanged?: boolean; }); /** * Reads data from given file and caches it. If file is not present, returns default data to be saved with [[DataFile.save]] or [[save]} methods. * If same data file requested multiple times returns cached data file. Absolute path of the file is used as cache key. * * @param path is the path of the file. Could be an absolute path or relative to root path option provided to [[Manager]]. * @param options are options * @returns [[DataFile]] instance. * @example * manager.load("package.json"); * manager.load("eslint", { defaultFormat: "json", cosmiconfig: { options: { packageProp: "eslint" }, searchForm: "some/path" } }) */ load(path: string, options?: ManagerLoadOptions): Promise; /** * Creates [[DataFile]] instance from given data and returns it. Also caches the data. * * @param path is the path of the file. Could be an absolute path or relative to root path option provided to [[Manager]] * @param data is the data to create [[DataFile]] from. * @param options are options * @returns [[DataFile]] instance. */ fromData(path: string, data: object, options?: ManagerFromDataOptions): Promise; /** * Reads data from all given files and caches them. If same data file requested multiple times returns cached data file. Absolute path of the file is used as cache key. * * @param paths are arry of paths of the files. Could be an absolute path or relative to root path option provided to [[Manager]]. * @param options are options. * @param options.defaultFormat is the default format to be used if file format cannot be determined from file name and content. * @param options.defaultData is the default data to be used if file does not exist. * @param options.saveIfChanged is whether to save file only if data is changed. Clones initial data deeply to check during save. */ loadAll(paths: string[], options?: { defaultFormat?: WritableFileFormat; defaultData?: any; readOnly?: boolean; saveIfChanged?: boolean; }): Promise; /** * Saves all files. */ saveAll(): Promise; } //# sourceMappingURL=manager.d.ts.map