Create public configuration for the project
npm install --save y-config
javascript:
const Config = require("y-config");
typescript:
import Config = require("y-config");
const config = new Config();
config.addConfigPath('./config.json');
config.addConfigPath('./config.yaml');
const config = new Config();
config.addConfigPath('./config', 'json');
const config = new Config();
config.addConfigPath('./config', 'yaml');
const config = new Config();
config.addParser({
format: 'ini',
filter: /\.ini$/,
handler: (filepath) => {
const fs = require('fs');
const ini = require('ini');
return ini.parse(fs.readFileSync('./config.ini', 'utf-8'))
}
});
const config = new Config();
config.addConfig({
baz: "foo"
});
const config = new Config();
// ......
config.getConfig();