Socket
Socket
Sign inDemoInstall

yfm-concat

Package Overview
Dependencies
28
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    yfm-concat

Concatenate YAML front matter from several files into one object


Version published
Maintainers
1
Install size
4.21 MB
Created

Readme

Source

yfm-concat

Concatenate the YAML front matter of a glob of files.

Usage

Given two files, foo.yaml and bar.yaml that look like this:

---
# foo.yaml
foo: oh wow
---
# bar.yaml
bar: neato keen

You can do this in node:

> var yfmConcat = require('yfm-concat');
> var result = yfmConcat('*.yaml');
{
    'bar.yaml': {
        bar: 'neato keen'
    },
    'foo.yaml': {
        'foo': 'oh wow'
    }
}

Or this on the command line:

$ yfm-concat '*.yaml'
---
bar.yaml:
    bar: neato keen
foo.yaml
    foo: oh wow
---

Usage

  Usage: yfm-concat [options] <file ...>

  Concatenate the YAML front matter of several files

    -V, --version             output the version number
    -o, --output <file>       Save result to file
    -f, --format <format>     Output format (YAML or JSON)
    -C, --cwd <path>          Output with keys relative to this path
    -d, --delims <delimiter>  YAML delimiter
    -i, --indent <indent>     Number of spaces to indent

Example:

$ yfm-concat 'foo/*.yaml' 'foo/bar/*.yaml' --cwd foo --delims +++ -o result.yaml
$ cat result.yaml
+++
foo.yaml:
    foo: oh wow
bar.yaml:
    bar: neato.keen
+++

The delims flag can take a comma-separated list of two different delimters. If you don't want any trailing delimeter, end your delimiter with a comma.

$ yfm-concat foo/*.yaml foo/bar/*.yaml --delims ---,
---
foo.yaml:
    foo: oh wow
bar.yaml:
    bar: neato keen

API

yfmConcat(pattern, options)

  • pattern: A file, list of files, or glob.
  • options: A javascript object. The default looks like this:

var opts = {
    // (String) The keys in the output are the input filenames. Interpret them relative to this
    // ignored if 'merge' is set
    cwd: '.',

    // The start and end delimiter for the output YAML
    delims: ['---', '---'],

    // (string) return format
    // if empty, function returns a Javascript object
    // valid formats: 'yaml', 'json'
    format: null,

    // (Integer) number of spaces to indent
    indent: 4,

    // Object to extend with the result (js only)
    extend: {},

    // (Boolean) whether to merge all the front matter into a single object
    merge: false,
}

Keywords

FAQs

Last updated on 04 Mar 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc