1.0.0 • Published 7 years ago
@brainhubeu/hadron-json-provider v1.0.0
Installation
npm install @brainhubeu/hadron-json-provider --saveOverview
JSON Provider allows you to automatically load multiple files as JSON object, with file names as object keys, and files data as object values. Currently we support following extensions:
.js.json.xml
Module functions
Basic provider
jsonProvider(paths, extensions);paths- array of strings which contains paths to filesextensions- array of strings which contains extensions of files from which you want to build an JSON object
For example, having directory with the following structure:

To find all files in ./routing and its sub-directories with extension config.js you can use following code:
jsonProvider(['./routing/**/*'], ['config.js'])
.then((object) => {})
.catch((error) => {});Configuration Provider
configJsonProvider(paths, configFile, projectType, extensions);paths- array of strings which contains paths to filesconfigFile- name of main configuration fileprojectType- project typeextensions- array of strings which contains extensions of files from which you want to build an JSON object
For example, having directory with the following structure:

If you want to build configuration object which depends on project type, for example development you can use following code
configJsonProvider(['./app/config/*'], 'config', 'development', ['xml', 'js'])
.then((object) => {})
.catch((error) => {});