A Sumor Cloud Tool.
More Documentation
Config Loader support .yml, .yaml, .json and .config.js files. It can load all files in a directory.
npm i @sumor/config --save
Require Node.JS version 18.x or above
As this package is written in ES module,
please change the following code in your package.json
file:
{
"type": "module"
}
import { load } from '@sumor/config'
const config = await load(process.cwd(), 'config')
// will load config.yml, config.yaml, config.json, config.config.js
load all files in the directory
import { meta } from '@sumor/config'
const config = await meta(process.cwd(), ['js', 'sql'])
/*
Demo directory structure
- root
- car.json
- car.sql
- ship.js
- plane.yml
- truck.config.js
*/
// it will load all config files as below
/*
{
car: {
name: 'car',
sql: "..."
},
ship: {
name: 'ship'
js: '<root>/ship.js'
},
plane: {
name: 'plane'
},
truck: {
name: 'truck'
}
*/