config-yaml
v1.1.6
Published
YAML configuration for NodeJS
Downloads
9,087
Readme
config-yaml
YAML configuration for NodeJS
Basic example
config/default.yml
:
foo: "bar"
list:
- 1
- 2
- 3
import configYaml from "config-yaml";
const config = configYaml(`${__dirname}/config/default.yml`);
console.log(config.foo); // "bar"
console.log(config.list[1]); // 2
Example with imports
directive
config/production.yml
:
imports:
- { resource: "default.yml" }
- { resource: "routing/api.yml", property: "routing.api" }
foo: "hello"
tic: "tac"
import configYaml from "config-yaml";
const config = configYaml(`${__dirname}/config/production.yml`);
console.log(config.foo); // "hello"
console.log(config.routing.api); // Configuration from routing/api.yml
Available variables
| Variable | Description |
| -------------- | --------------------------------------- |
| %__dirname%
| Directory path of the current YAML file |
| %__filename%
| Current YAML file path |