This package has been deprecated

Author message:

the project is outdated, use natan

fs-settings-loader

1.0.2 • Public • Published

fs-settings-loader

npm i fs-settings-loader
var loader = require('fs-settings-loader')
var settings = loader('./configs/dev.json')

parent

Config files may overlap. To do this, you must specify the path to a parent file:

//bundle.global.json
{
    "logger": { "Console": { "level": "info" } },
    "firstAppPort": 8080,
    "secondAppPort": 8081
}
 
//bundle.firstApp.json
{
    "__parent__": "./bundle.global",
    "scanInterval": "t{ 10 minutes }",
    "secondAppAddress": "http://locahost:#{ secondAppPort }"
}
 

stacking order: bundle.global.json < bundle.firstApp.json

default

Multiple config files can have a common default file, eg:

//app.default.json
{
    "insertTemplate": "INSERT table_name SET ?"
}
//app.dev.json
{
    "db": { "host": "localhost" }
}
//app.prod.json
{
    "db": { "host": "server-address" }
}

stacking order: app.default.json < app.dev.json
stacking order: app.default.json < app.prod.json

local

Each configuration file, other than the default file, can have a local configuration file:

//app.default.json
{
    "delayBeforeStart": "t{ 10 seconds }",
    "delayBeforeStop": "t{ 10 seconds }",
    "pingInterval": "t{ 10 seconds }",
    "initProblemTimeout": "t{ 60 seconds }",
 
    "minIntervalOfPlannedRestart": "t{ 1 hour  }",
    "maxIntervalOfPlannedRestart": "t{ 2 hours }"
}
 
//app.dev.json
{
    "startCmd": "notify-send 'startCmd - google-chrome'",
    "stopCmd": "notify-send 'stopCmd - killall chrome'"
}
//app.dev.local.json
{
    "minIntervalOfPlannedRestart": "t{ 15 seconds }",
    "maxIntervalOfPlannedRestart": "t{ 16 seconds }"
}

stacking order: app.default.json < app.dev.json < app.dev.local.json

interpolation

properties interpolation:

{
    "port": 8080,
    "address": "http://locahost:#{ port }"
} 

convert human-readeble time intervals to milliseconds:

{
    "interval": "t{ 1 hour }"
}

resolve paths by cwd:

{
    "cwd": "p{ ./ }"
}

exec functins:

{
    "prop": "some data",
    "propLength": "@{ this.prop.length }"
}

interpolation order: functions < paths < time < properties

Readme

Keywords

Package Sidebar

Install

npm i fs-settings-loader

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • nskazki