gendiff
This is the second project from Hexlet Frontend Program.
Demonstration of gendiff on Replit
Difference generator:
This utility compares two files and generates their difference. Structures can be deep.
Supports .json
, .yaml
or .ini
as inputs.
Can output in:
stylish
- readable united structure that marks changes with+
and-
signs (this is default option),plain
- description of properties that were added, removed or updated,json
- string with json formatting.
Examples (asciinema):
1. compare flat json files
2. compare flat yaml files
3. compare flat ini files
4. output to stylish
5. output to plain
6. output to json
Installing:
- Clone this repository to your filesystem:
git clone https://github.com/dpetruk/frontend-project-lvl2.git
- Go to directory
frontend-project-lvl2
and create links:
npm link
Running as CLI-app:
gendiff <filename1> <filename2>
Options:
-f
, --format
- specify output format (stylish
- default, plain
or json
).
-h
, --help
- get help.
Using as library:
import genDiff from 'gendiff';
// outputFormat can be 'stylish', 'plain' or 'json'. Default option is 'stylish'.
const diff = genDiff(filepath1, filepath2, outputFormat);
console.log(diff);