Socket
Book a DemoInstallSign in
Socket

config-cjson

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-cjson

Load cjson config files

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

config-cjson

A small utility to load config files written in cjson (JSON with comments).

Inspiration: https://www.npmjs.com/package/oconf

usage

  • Use as a module
    const  pathModule = require('path');
    const loadConfig = require("config-cjson");
    .
    .
    .
    const config = await loadConfig(
        pathModule.resolve(__dirname, "..", "config", "development.cjson")
    );
    
  • Use as CLI - prints config in the terminal
    ./node_modules/.bin/config-cjson <config file path>
    

supported directives

  • #include - directive to include parent configs, path to included config can be relative(relative to the first config loaded) or absolute.

    {
        "#include": "common.cjson",
        .
        .
        .
    }
    

    or

    {
        "#include": ["common.cjson", "production.cjson"],
        .
        .
        .
    }
    
  • #public - directive to expose a property on a separate #public attribute.

    {
        ...
        "title#public": "My App"
        ...
    }
    

    or

        ...
        "lang#public": {
            "defaultLocale": "en-US",
            "supportedLocales: ["en-US", "es-ES"]
        }
        ...
    

    Below is not supported

    # Not supported
    "#public": {
        "lang" : {
            "defaultLocale": "en-US"
        }
    }
    

Keywords

config

FAQs

Package last updated on 24 Dec 2022

Did you know?

Socket

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