1.1.1 • Published 3 years ago

@vaziliybober/gendiff v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Gendiff

Maintainability Test Coverage Continuous integration workflow

Gendiff is an npm module that generates the difference between two configuration files and formats it into a string

The following configuration file types are supported: json (.json), yaml (.yml), ini (.ini)

This is the lvl-2 frontend project on https://ru.hexlet.io/

Example

In this example three pairs of files are containing the same data, but in different formats. Because the data itself is the same, the gendiff applied to all the three sets of data will lead to equal results:

{
  "number": 17,
  "obj": {
    "foo": "bar",
    "node": {
      "array": [1],
      "str": "asdf"
    }
  }
}
{
  - hello: world
  + number: 17
    obj: {
        foo: bar
        node: {
            array: [
                1
            ]
          - str: jkl;
          + str: asdf
        }
    }
}
Property 'hello' was removed
Property 'number' was added with value: 17
Property 'obj.node.str' was updated. From 'jkl;' to 'asdf'

[{"type":"leaf","name":"hello","status":"removed","value":"world"},{"type":"leaf","name":"number","status":"added","value":17},{"type":"node","name":"obj","children":[{"type":"leaf","name":"foo","status":"unchanged","value":"bar"},{"type":"node","name":"node","children":[{"type":"leaf","name":"array","status":"unchanged","value":1},{"type":"leaf","name":"str","status":"modified","valueBefore":"jkl;","valueAfter":"asdf"}]}]}]

hello: world
obj:
  foo: bar
  node:
    array:
      - 1
    str: jkl;
hello=world

[obj]
foo=bar

[obj.node]
array[]=1
str=jkl\;
number=17

[obj]
foo=bar

[obj.node]
array[]=1
str=asdf

Install

npm install -g @vaziliybober/gendiff

Clone

git clone https://github.com/vaziliybober/gendiff.git
cd gendiff/
make install
make link

Use

Usage: gendiff [options] <filepath1> <filepath2>

Compares two configuration files and shows a difference.

Options:
  -V, --version        output the version number
  -f, --format [type]  output format (default: "stylish")
  -h, --help           output usage information

Demo