A Sumor Cloud Tool.
More Documentation
Config Loader support yaml and json files. It can load all files in a directory.
And automatically convert the file to the specified format.
npm i @sumor/config --save
Require Node.JS version 16.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'
import { find } from '@sumor/config'
import { findReference } from '@sumor/config'
import { load } from '@sumor/config'
const config1 = await load(process.cwd(), 'demo')
// it will load demo.yml or demo.json in root directory
const config2 = await load(process.cwd(), 'demo', 'yaml')
// it will load demo.yml or demo.json in root directory, and convert it to yaml format file
import { find } from '@sumor/config'
const config = await find(process.cwd(), 'entity')
// it will load all *.entity.yml or *.entity.json in root directory
/*
* example:
* car.entity.yml, bike.entity.json
* {
* "car": {...}
* "bike": {...}
* }
* */
such as .vue, .js files, it has same name config file
import { findReference } from '@sumor/config'
const config = await findReference(process.cwd(), ['vue', 'js'])
// it will load all *.entity.yml or *.entity.json which has same name with *.vue or *.js in root directory
/*
* example:
* car.entity.yml, bike.entity.json
* car.vue, bike.js
* {
* "car": {...}
* "bike": {...}
* }
* */