Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc - npm Package Compare versions

Comparing version 0.6.0 to 1.0.0

46

index.js

@@ -23,26 +23,32 @@ #! /usr/bin/env node

function file () {
var content = cc.file.apply(null, arguments)
return content ? parse(content) : null
var env = cc.env(name + '_')
var configs = [defaults]
var configFiles = []
function addConfigFile (file) {
var fileConfig = cc.file(file)
if (fileConfig) {
configs.push(parse(fileConfig))
configFiles.push(file)
}
}
var local = cc.find('.'+name+'rc')
// which files do we look at?
if (!win)
[join(etc, name, 'config'),
join(etc, name + 'rc')].forEach(addConfigFile)
if (home)
[join(home, '.config', name, 'config'),
join(home, '.config', name),
join(home, '.' + name, 'config'),
join(home, '.' + name + 'rc')].forEach(addConfigFile)
addConfigFile(cc.find('.'+name+'rc'))
if (env.config) addConfigFile(env.config)
if (argv.config) addConfigFile(argv.config)
var env = cc.env(name + '_')
return deepExtend.apply(null, [
defaults,
win ? {} : file(join(etc, name, 'config')),
win ? {} : file(join(etc, name + 'rc')),
home ? file(join(home, '.config', name, 'config')) : {},
home ? file(join(home, '.config', name)) : {},
home ? file(join(home, '.' + name, 'config')) : {},
home ? file(join(home, '.' + name + 'rc')) : {},
file(local),
local ? {config: local} : null,
env.config ? file(env.config) : null,
argv.config ? file(argv.config) : null,
return deepExtend.apply(null, configs.concat([
env,
argv
])
argv,
configFiles.length ? {configs: configFiles, config: configFiles[configFiles.length - 1]} : null,
]))
}

@@ -49,0 +55,0 @@

{
"name": "rc",
"version": "0.6.0",
"version": "1.0.0",
"description": "hardwired configuration loader",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -29,3 +29,12 @@ # rc

If `rc` finds any config files for your app, the returned config object will have
a `configs` array containing their paths:
```javascript
var appCfg = require('rc')(appname, conf);
appCfg.configs[0] // /etc/appnamerc
appCfg.configs[1] // /home/dominictarr/.config/appname
appCfg.config // same as appCfg.configs[appCfg.configs.length - 1]
```
## Standards

@@ -32,0 +41,0 @@

@@ -56,2 +56,5 @@

assert.equal(commentedJSON.envOption, 42)
assert.equal(commentedJSON.config, jsonrc)
assert.equal(commentedJSON.configs.length, 1)
assert.equal(commentedJSON.configs[0], jsonrc)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc