Skip to content
A simple script that loads json files into a config object for use in an app.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE.md
README.md
index.js
package.json
test.js

README.md

Version License Author

ConfigJS Loader

A simple config loader, that loads JSON files and returns an object of the loaded files and their contents.

Installation

It's a simple NPM package, so just run a normal NPM installation

npm i configjs-loader

Usage

See the test script below for example usage. All you need to supply as an argument is the directory that contains the config files. The script will attempt to recurse over that directory, finding all JSON files, and attempting to parse them. Returns a promise that must be awaited, which then returns the object of the configs loaded.

Configuration files are loaded into an object based on their filename. For example, if you have 2 config files, one.json and two.json, their properties will be loaded into {}.one and {}.two, respectively.

'use strict';
const configLoader = require("configjs-loader");
const path = require("path");

(async ()=>{
  const conf = await configLoader(path.join(__dirname, "configs"));
  console.log(conf);
})();
You can’t perform that action at this time.