
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
load-config-file
Advanced tools
Load the config file as a plain object. The config file format can be registered.
Load the config file as a plain object.
loadConfig.setFileSystem(fs)
fs.path = require('path.js/lib/path').path
for the virtual POSIX path.
import { Config as loadConfig } from 'load-config-file'
import { parse as parseYaml } from 'yaml'
import * as cson from 'cson';
loadConfig.register(['.yaml', '.yml'], parseYaml); //first search.
loadConfig.register('.cson', cson.parseCSONString.bind(cson)); //second search
loadConfig.register('.json', JSON.parse); //third search.
//Synchronously load config from file.
//it will search config.yaml, config.yml, config.cson, config.json in the current folder.
//the first exist file will be loaded.
//the default encoding is "utf8" if no encoding.
//loadConfig('config', {encoding: 'ascii'})
//the non-enumerable "$cfgPath" property added.
console.log(loadConfig('config'));
const result = await loadConfig('config')
//Asynchronously load config from file
loadConfig('config', function(err, result){
if (err) {
console.log('error:', err);
} else {
console.log(result);
}
})
var config = require('load-config-file');
config.register(extensionNames, parserFunc)
: register the configuration file format to
load. return the configurators if successful.
extensionNames
(Sting|ArrayOf String): the configuration file extension name(s)
with dot.parserFunc
Function(context): the configuration context parser function:
config.setFileSystem(fs)
: set your favour file system. defaults to 'fs'.
readFile(path[, options], done)
and readFileSync(path[, options])
load(path, options, done)
: Asynchronously load config from file
raiseError
(Boolean): raise error if nothing loaded defaults to false.exclude
(String|ArrayOf String): excludes some files.encoding
(String): the file encoding name. defaults to 'utf8'.$cfgPath
property added if successful.loadSync(path, options)
: Synchronously load config from file
$cfgPath
property added if successful.raiseError option to load function asynchronously.
add the $cfgPath
(String) non-enumerable property to the result.
add object usage supports:
var cfgObj = new Config(aPath, aOptions) //create a configuration object.
result = cfgObj.loadSync()
MIT
FAQs
Load the config file as a plain object. The config file format can be registered.
The npm package load-config-file receives a total of 921 weekly downloads. As such, load-config-file popularity was classified as not popular.
We found that load-config-file demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.