yaml-inject
v1.0.1
Published
Inject partial .yml files into a property in a main.yml file
Downloads
16
Readme
YAML Inject
This is a simple npm module which injects the contents of the partial .yaml files into a specific property of the main .yaml file.
Example
Let's say you have the following files:
main.yaml:
title: "Team"
players:
description: "This is a soccer team."
partial1.yaml:
bob:
name: "Bob"
partial2.yaml:
steve:
name: "Steve"
age: 15
This module can then generate output.yaml with the following contents:
title: "Team"
players:
bob:
name: "Bob"
steve:
name: "Steve"
age: 15
description: "This is a soccer team."
Usage
You can either include src/index.js in another script and call the exported function:
const yamlInject=require('yaml-inject')
yamlInject(mainFilePath,partialsGlobString,outputFilePath,propertyPath)
or you can call the binary directly from the command line:
npx yaml-merge --main <mainFilePath> --partials <partialsGlobString> --output <outputFilePath> --property <propertyPath>
where:
- mainFilePath is the path to the main YAML file
- partialsGlobString is the glob string to match the partial YAML files (e.g. 'partials/*.yml')
- outputFilePath is the path where the merged YAML file will be saved
- propertyPath is the property path in the main file where the partial YAML contents should be inserted (e.g. 'players')