yaml-compose

2.0.0 • Public • Published

yaml-compose

npm version Build Status

Gitlab influenced way of composing yaml files by using the include keyword

Usage via CLI

Install package globally.

$ npm install yaml-compose -g

Given that you have the following yaml files.

// Content of source.yml

include: "./include.yml"

variableA: "a"

// Content of include.yml

variableB: "b"

You can use the following command to compose the yaml file.

$ yaml-compose source.yaml -o dist

// Content of dist/source.yml

variableA: "a"
variableB: "b"

Alternativly you can also use npx and not install it globally.

$ npx yaml-compose source.yaml -o dist

Usage as a module

Example:

const { build: yamlCompose } = require('yaml-compose')
const yaml = await build('source.yml' )

The build function has two arguments build(sourceFile, options): -sourceFile: The path to the source file

  • options: An options object with two recognized properties:
    • getFile: An async function used to read yaml files (i.e. the original source and all included files)
      Defaults to src => fs.readFileSync(src, 'utf-8')
    • resolvePath: Function used to resolve the relative path given for includes in the source file.
      Defaults to (sourcePath, includePath) => path.resolve(path.dirname(sourcePath), includePath)

Readme

Keywords

Package Sidebar

Install

npm i yaml-compose

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

9.94 kB

Total Files

17

Last publish

Collaborators

  • herrmannplatz