Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herrmannplatz/yaml-compose
Composing yaml files by using the include keyword
https://github.com/herrmannplatz/yaml-compose
Last synced: about 2 months ago
JSON representation
Composing yaml files by using the include keyword
- Host: GitHub
- URL: https://github.com/herrmannplatz/yaml-compose
- Owner: herrmannplatz
- License: mit
- Created: 2018-10-21T21:27:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T14:24:53.000Z (about 6 years ago)
- Last Synced: 2024-10-13T14:15:05.113Z (3 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/yaml-compose
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yaml-compose
[![npm version](https://badge.fury.io/js/yaml-compose.svg)](https://badge.fury.io/js/yaml-compose) [![Build Status](https://travis-ci.org/herrmannplatz/yaml-compose.svg?branch=master)](https://travis-ci.org/herrmannplatz/yaml-compose)
> 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.ymlinclude: "./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)`