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

Comparing version 0.1.7 to 0.1.8

docs/usage.md

2

bower.json
{
"name": "align-yaml",
"version": "0.1.7",
"version": "0.1.8",
"main": [

@@ -5,0 +5,0 @@ "index.js"

@@ -5,10 +5,4 @@ # {%= name %} {%= badge("fury") %}

## Install
{%= include("install") %}
Reformats this:
## Usage
Messy YAML (`foo.yml`):
```yaml

@@ -20,13 +14,4 @@ one: two

Read in the YAML as a string, don't parse it:
to this:
```js
var align = require('align-yaml');
var str = require('fs').readFileSync('foo.yml').toString();
align(str);
```
Pretty YAML:
```yaml

@@ -38,21 +23,8 @@ one: two

### pad
## Install
{%= include("install-global") %}
Or, pass in a number:
## Usage
{%= docs("usage") %}
```js
align(str, 15);
```
Results in:
```yaml
one: two
three: four
seventeen: five
```
See [the tests](./test/test.js) for a basic example.
## Author

@@ -59,0 +31,0 @@ {%= contrib("jon") %}

{
"name": "align-yaml",
"description": "Format, prettify, align, whatever you want to call it. This does that to YAML.",
"version": "0.1.7",
"description": "Format, prettify, align, whatever you want to call it. This does that to YAML. Great for making long config files more readable!",
"version": "0.1.8",
"homepage": "https://github.com/jonschlinkert/align-yaml",

@@ -24,9 +24,7 @@ "author": {

"keywords": [
"docs",
"documentation",
"generate",
"generator",
"markdown",
"templates",
"verb"
"yaml",
"format",
"beautify",
"prettify",
"align"
],

@@ -48,8 +46,8 @@ "main": "index.js",

"dependencies": {
"cwd": "~0.1.0",
"verbalize": "~0.1.0",
"fs-utils": "~0.4.0",
"longest": "~0.2.1",
"minimist": "~0.0.8",
"repeat-string": "~0.1.0",
"longest": "~0.2.1"
"verbalize": "~0.1.2"
}
}
}
# align-yaml [![NPM version](https://badge.fury.io/js/align-yaml.png)](http://badge.fury.io/js/align-yaml)
> Format, prettify, align, whatever you want to call it. This does that to YAML.
> Format, prettify, align, whatever you want to call it. This does that to YAML. Great for making long config files more readable!
Reformats this:
```yaml
one: two
three: four
seventeen: five
```
to this:
```yaml
one: two
three: four
seventeen: five
```
## Install
Install with [npm](npmjs.org):
Install globally with [npm](npmjs.org):
```bash
npm i align-yaml --save-dev
npm i -g align-yaml
```
## Usage
### CLI
Messy YAML (`foo.yml`):
From the command line, use:
```yaml
one: two
three: four
seventeen: five
```bash
align [source file] [destination] [padding]
```
Read in the YAML as a string, don't parse it:
#### flags
```js
var align = require('align-yaml');
var str = require('fs').readFileSync('foo.yml').toString();
**All arguments are optional**
align(str);
* `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:
```bash
align **/*.yml
```
Pretty YAML:
#### padding
By default, all values are formatted to be aligned to the longest key with one space of padding. e.g.
```yaml

@@ -39,20 +65,29 @@ one: two

```
To add extra padding, just do something like `align foo.yml -p 10`, to get:
### pad
```yaml
one: two
three: four
seventeen: five
```
Or, pass in a number:
### API
There isn't much of an API, just do:
```js
align(str, 15);
var align = require('align-yaml');
```
Results in:
Then pass a string to `align(str)`. This is important! **Read in the YAML as a string, DON'T PARSE IT**.
```yaml
one: two
three: four
seventeen: five
Just do this, and you'll be fine:
```js
var fs = require('fs');
var str = fs.readFileSync('foo.yml', 'utf8');
align(str, padding);
```
See [the tests](./test/test.js) for a basic example.

@@ -73,2 +108,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 01, 2014._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 13, 2014._

Sorry, the diff of this file is not supported yet

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