Skip to content

plundell/yaml-inject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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')

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published