Gathering detailed insights and metrics for run-con
Gathering detailed insights and metrics for run-con
Gathering detailed insights and metrics for run-con
Gathering detailed insights and metrics for run-con
con-task-runner
Simple library to enable you run task concurrently.
mdlinks-run
librería desarrollada con Node.js para validar links de archivos markdown
bash-node-run
Un simple comando para ejecutar los de comandos de `package.json` con [npm].
run-validator-pack
Paquete con herramientas para validar, formatear y enmascarar rol unico nacional chileno
The non-configurable configuration loader for lazy people.
npm install run-con
Typescript
Module System
Node Version
NPM Version
99
Supply Chain
98.9
Quality
75.3
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
50,067,712
Last Day
40,462
Last Week
571,008
Last Month
2,384,805
Last Year
19,916,580
NOASSERTION License
7 Stars
197 Commits
2 Forks
3 Watchers
9 Branches
26 Contributors
Updated on Jan 17, 2024
Minified
Minified + Gzipped
Latest Version
1.3.2
Package Id
run-con@1.3.2
Unpacked Size
18.86 kB
Size
7.75 kB
File Count
16
NPM Version
8.19.2
Node Version
16.18.1
Published on
Jun 19, 2023
Cumulative downloads
Total Downloads
Last Day
-17.1%
40,462
Compared to previous day
Last Week
-3%
571,008
Compared to previous week
Last Month
6.1%
2,384,805
Compared to previous month
Last Year
31.4%
19,916,580
Compared to previous year
4
Based on
RC
The non-configurable runtime configuration loader for lazy people.
The only option is to pass run-con the name of your app, and your default configuration.
1var conf = require('run-con')(appname, { 2 //defaults go here. 3 port: 2468, 4 5 //defaults which are objects will be merged, not replaced 6 views: { 7 engine: 'jade' 8 } 9});
run-con
will return your configuration options merged with the defaults you specify.
If you pass in a predefined defaults object, it will be mutated:
1var conf = {}; 2require('run-con')(appname, conf);
If run-con
finds any config files for your app, the returned config object will have
a configs
array containing their paths:
1var appCfg = require('run-con')(appname, conf); 2appCfg.configs[0] // /etc/appnamerc 3appCfg.configs[1] // /home/dominictarr/.config/appname 4appCfg.config // same as appCfg.configs[appCfg.configs.length - 1]
Given your application name (appname
), run-con will look in all the obvious places for configuration.
--foo baz
, also nested: --foo.bar=baz
)${appname}_
appname_foo__bar__baz
=> foo.bar.baz
)--config file
then from that file.${appname}rc
or the first found looking in ./ ../ ../../ ../../../
etc.$HOME/.${appname}rc
$HOME/.${appname}/config
$HOME/.config/${appname}
$HOME/.config/${appname}/config
/etc/${appname}rc
/etc/${appname}/config
All configuration sources that were found will be flattened into one object, so that sources earlier in this list override later ones.
Configuration files (e.g. .appnamerc
) may be in either json or ini format. No file extension (.json
or .ini
) should be used. The example configurations below are equivalent:
ini
; You can include comments in `ini` format if you want.
dependsOn=0.10.0
; `run-con` has built-in support for ini sections, see?
[commands]
www = ./commands/www
console = ./commands/repl
; You can even do nested sections
[generators.options]
engine = ejs
[generators.modules]
new = generate-new
engine = generate-backend
json
1{ 2 // You can even comment your JSON, if you want 3 "dependsOn": "0.10.0", 4 "commands": { 5 "www": "./commands/www", 6 "console": "./commands/repl" 7 }, 8 "generators": { 9 "options": { 10 "engine": "ejs" 11 }, 12 "modules": { 13 "new": "generate-new", 14 "backend": "generate-backend" 15 } 16 } 17}
Comments are stripped from JSON config via strip-json-comments.
Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.
To ensure that string representations of booleans and numbers are always converted into their proper types (especially useful if you intend to do strict ===
comparisons), consider using a module such as parse-strings-in-object to wrap the config object returned from run-con.
Assume you have an application like this (notice the hard-coded defaults passed to run-con):
const conf = require('run-con')('myapp', {
port: 12345,
mode: 'test'
});
console.log(JSON.stringify(conf, null, 2));
You also have a file config.json
, with these contents:
{
"port": 9000,
"foo": "from config json",
"something": "else"
}
And a file .myapprc
in the same folder, with these contents:
{
"port": "3001",
"foo": "bar"
}
Here is the expected output from various commands:
node .
{
"port": "3001",
"mode": "test",
"foo": "bar",
"_": [],
"configs": [
"/Users/stephen/repos/conftest/.myapprc"
],
"config": "/Users/stephen/repos/conftest/.myapprc"
}
Default mode
from hard-coded object is retained, but port is overridden by .myapprc
file (automatically found based on appname match), and foo
is added.
node . --foo baz
{
"port": "3001",
"mode": "test",
"foo": "baz",
"_": [],
"configs": [
"/Users/stephen/repos/conftest/.myapprc"
],
"config": "/Users/stephen/repos/conftest/.myapprc"
}
Same result as above but foo
is overridden because command-line arguments take precedence over .myapprc
file.
node . --foo barbar --config config.json
{
"port": 9000,
"mode": "test",
"foo": "barbar",
"something": "else",
"_": [],
"config": "config.json",
"configs": [
"/Users/stephen/repos/conftest/.myapprc",
"config.json"
]
}
Now the port
comes from the config.json
file specified (overriding the value from .myapprc
), and foo
value is overridden by command-line despite also being specified in the config.json
file.
argv
You may pass in your own argv
as the third argument to run-con
. This is in case you want to use your own command-line opts parser.
1require('run-con')(appname, defaults, customArgvParser);
If you have a special need to use a non-standard parser, you can do so by passing in the parser as the 4th argument. (leave the 3rd as null to get the default args parser)
1require('run-con')(appname, defaults, null, parser);
This may also be used to force a more strict format, such as strict, valid JSON only.
run-con
is running fs.statSync
-- so make sure you don't use it in a hot code path (e.g. a request handler)
Original author is @dominictarr
Multi-licensed under the two-clause BSD License, MIT License, or Apache License, version 2.0
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/18 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More