A difference calculator is a program that determines the difference between two data structures. This is a popular task for which there are many online services, such as http://www.jsondiff.com/. A similar mechanism is used when outputting tests or when automatically tracking changes in configuration files.
Features of the calculator:
- Supports various input formats: yaml, json
- Report generation as plain text, stylish and json
Current version: 0.0.9
gendiff -h or gendiff --help
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 display help for command
# plain format
gendiff --format plain path/to/file.yml another/path/file.json
Property 'common.follow' was added with value: false
Property 'group1.baz' was updated. From 'bas' to 'bars'
Property 'group2' was removed
# stylish format
gendiff filepath1.json filepath2.json
{
+ follow: false
setting1: Value 1
- setting2: 200
- setting3: true
+ setting3: {
key: value
}
+ setting4: blah blah
+ setting5: {
key5: value5
}
}
Make sure you have installed Node.js version 16 or higher.
- Clone repo:
git clone git@github.com:chickenzombie/frontend-project-46.git
- Change directory:
cd frontend-project-46
- Install packages:
make install
You can use short version of data input (more information in Makefile). 2 json files are compared by default.
make diff
or for example calculate difference between 2 yaml files:
make diff-yml
make diff-plain
make diff-yml-plain
make diff-json
make diff-yml-json