-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcosmiconfig.node.txt
53 lines (49 loc) · 3.53 KB
/
cosmiconfig.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
┏━━━━━━━━━━━━━━━━━┓
┃ COSMICONFIG ┃
┗━━━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - rc:
# - supports JSON|INI files
# - looks in --OPT, ENVVAR, --config, .NAMErc, $HOME/.config/NAME, /etc/NAMErc
# - merge between each found
# - sync
# - cosmiconfig (prefered except if need ENVVAR support):
# - supports JavaScript|JSON|YAML files
# - looks in --config, package.json, .NAMErc, NAME.config.js
# - stops at first found
# - a little more maintained
# - async
VERSION ==> #2.2.2
COSMICONFIG('NAME'[, OPTS])->EXPL #Finds config CONF:
EXPL.load(DIR or null, ARG_FILE) # - among, in order:
->PROMISE_CCONF # - ARG_FILE
# - OPTS.configPath JSON|YAML|JS_FILE
# - --config JSON|YAML|JS_FILE
# - ./[../.../]package.json NAME CONF
# - ./[../.../].NAMErc JSON|YAML_FILE
# - ./[../.../].NAMErc.json|y[a]ml|js JSON|YAML|JS_FILE
# - ./[../.../]NAME.config.js JS_FILE
# - ../... stops at $HOME
# - can specify DIR instead of $PWD
# - uses the first file found only
#Result:
# - CCONF is { config CONF, filepath STR }
# - returns PROMISE_null if nothing is found.
# - reject PROMISE if CONF is malformed.
#OPTS:
# - argv|packageProp|rc|js STR|BOOL:
# - change the NAME searched in --config, package.json, .NAMErc[*] or NAME.config.js
# - BOOL false disables
# - rcExtensions BOOL (def: false): enables .NAMErc.json|y[a]ml|js
# - stopDir STR: used instead of $HOME
# - sync BOOL (def: false)
# - cache BOOL (def: true):
# - each EXPL has its own cache
# - can also manipulate it with EXPL.clearCaches|FileCache|DirectoryCache()
# (for ARG_FILE, DIR or both)
# - rcStrictJson BOOL (def: false): use JSON.parse() instead of js-yaml,
# i.e. no YAML allowed, and JSON is less permissive
# - transform(CCONF)->PROMISE_CONF:
# - applied to final CONF
# - reason to use this instead of just modifying return value is to use cosmiconfig
# caching
#YAML uses js-yaml with DEFAULT_SAFE_SCHEMA