Socket
Socket
Sign inDemoInstall

align-yaml

Package Overview
Dependencies
25
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

align-yaml

Format, prettify, align, whatever you want to call it. This does that to YAML. Great for making long config files more readable!


Version published
Maintainers
1
Weekly downloads
77
decreased by-3.75%
Install size
2.63 MB

Weekly downloads

Readme

Source

align-yaml NPM version

Format, prettify, align, whatever you want to call it. This does that to YAML. Great for making long config files more readable!

Reformats this:

one: two
three: four
seventeen: five

to this:

one:       two
three:     four
seventeen: five

Install

Install globally with npm:

npm i -g align-yaml

Usage

CLI

From the command line, use:

align [source file] [destination] [padding]
flags

All arguments are optional

  • source: the source file. first argument or -s|--src
  • destination: the destination file path. second argument or -d|--dest
  • padding: the amount of padding to add next to each line. third argument or -p|--pad

Also:

  • If no source or dest is provided, align will search for any .yml or .yaml files in the current working directory and format them.
  • If a source is provided but no dest, the source file will be overwritten.

Glob patterns may also be used:

align **/*.yml
padding

By default, all values are formatted to be aligned to the longest key with one space of padding. e.g.

one:       two
three:     four
seventeen: five

To add extra padding, just do something like align foo.yml -p 10, to get:

one:                two
three:              four
seventeen:          five

API

There isn't much of an API, just do:

var align = require('align-yaml');

Then pass a string to align(str). This is important! Read in the YAML as a string, DON'T PARSE IT.

Just do this, and you'll be fine:

var fs = require('fs');
var str = fs.readFileSync('foo.yml', 'utf8');

align(str, padding);

See the tests for a basic example.

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on April 13, 2014.

Keywords

FAQs

Last updated on 13 Apr 2014

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