Socket
Socket
Sign inDemoInstall

configjs-loader

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    configjs-loader

A simple script that loads json files into a config object for use in an app.


Version published
Weekly downloads
7
increased by75%
Maintainers
1
Install size
10.2 kB
Created
Weekly downloads
 

Readme

Source

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);
})();

Keywords

FAQs

Last updated on 09 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc