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"
}
* root: string - root directory
* category: string - category name
* ext: string - file extension to convert (yml, json)
* root: string - root directory
* references: array - reference file extension (vue, js)
* ext: string - file extension to convert (yml, json)
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 the 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 the same name with *.vue or *.js in root directory
/*
* example:
* car.entity.yml, bike.entity.json
* car.vue, bike.js
* {
* "car": {...}
* "bike": {...}
* }
* */