UNPKG

curli-config

Version:

A small library to load/validate configuration files placed in different sides of the application using environments

36 lines (28 loc) 1.08 kB
import {FilesPathModel} from './FilesPathModel'; import {ConfigFilesPathModelInterface} from './ConfigFilesPathModelInterface'; export class FilesPathsCollection { private filesPaths: Array<FilesPathModel>; constructor ( paths: Array<ConfigFilesPathModelInterface> | ConfigFilesPathModelInterface ) { this.filesPaths = []; this.buildFilesPathsModel(paths); } public getPaths (): Array<FilesPathModel> { return this.filesPaths; } private buildFilesPathsModel ( paths: Array<ConfigFilesPathModelInterface> | ConfigFilesPathModelInterface ): void { if (Array.isArray(paths)) { paths.forEach((pathConfig: ConfigFilesPathModelInterface) => { this.buildFilesPathModel(pathConfig); }); } else { this.buildFilesPathModel(paths); } } private buildFilesPathModel (pathConfig: ConfigFilesPathModelInterface): void { this.filesPaths.push(new FilesPathModel(pathConfig.path)); } }