Skip to content

blazecolour/gendiff-cli

Repository files navigation

gendiff-cli

Maintainability Coverage Status Build Status

NPM

A tool for files differences by parsing them into AST, sorting them, and comparing the stringified output. Useful for finding changes in configuration files.

Install

CLI:

npm install -g gendiff-blazecolour-2

library:

npm install --save gendiff-blazecolour-2

Usage

CLI usage:

$ gendiff [options] <file1> <file2>

API usage:

import genDiff from 'gendiff-blazecolour-2';

genDiff('path/to/file1', 'path/to/file2', format);

CLI options

-v, --version        Output the version number
-f, --format [type]  Output format: tree, plain, json (default: tree)
-h, --help           Output usage information

Available format files

The following extensions are available for input files:

  • json
  • yml
  • ini

The output formats:

  • tree
  • plain
  • json

Examples

Comparing two json files.

Output

file1:

{
  "host": "hexlet.io",
  "timeout": 50,
  "proxy": "123.234.53.22",
  "follow": false
}

file2:

{
  "timeout": 20,
  "verbose": true,
  "host": "hexlet.io"
}

input

tree format:

{
    host: hexlet.io
  + timeout: 20
  - timeout: 50
  - proxy: 123.234.53.22
  + verbose: true
  - follow: false
}

plain format:

Property 'timeout' was changed. From '50' to '20'
Property 'proxy' was deleted
Property 'follow' was deleted
Property 'verbose' was added with value: 'true'

Asciinema

asciicast

License

MIT