Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

leebmann24/recursive-yaml-loader

Repository files navigation

@leebmann24/recursive-yaml-loader

loads yaml files recursively from a given folder. properties are grouped by it's filename (without extension) or foldername With this tool you are able to split up your configuration yamls into several files for clearity and maintainability.



install

$ npm install @leebmann24/recursive-yaml-loader

or

$ yarn add @leebmann24/recursive-yaml-loader


example

import loader from '@leebmann24/recursive-yaml-loader'

interface Config {
    file1: {
        property1: string
        list: string[]
    }
    
    aFolder: {
        file: string[]
    }
    
}


const config = loader.load('path/to/config/folder') as Config


parent/child combination

a file with the same name as the folder in which it's in will be merged into its "parent"

  • propXY (folder)
    • propXY.yml (will NOT be encapsulated)
      • hello: "world"
    • anotherProp.yml (will be encapsulated)
      • abc: "xyz"
{
    "propXY": {
        "hello": "world",
        "anotherProp": {
            "abc": "xyz"
        }
    }
}