dpetrouk / frontend-project-lvl2

CLI utility and library to generate differences between files (json, yaml, ini) and output them in different ways

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gendiff

Node CI Maintainability Test Coverage

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

Watch this recording at asciinema

2. compare flat yaml files

Watch this recording at asciinema

3. compare flat ini files

Watch this recording at asciinema

4. output to stylish

Watch this recording at asciinema

5. output to plain

Watch this recording at asciinema

6. output to json

Watch this recording at asciinema

Installing:

  1. Clone this repository to your filesystem:
git clone https://github.com/dpetruk/frontend-project-lvl2.git
  1. 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);

About

CLI utility and library to generate differences between files (json, yaml, ini) and output them in different ways


Languages

Language:JavaScript 98.0%Language:Makefile 2.0%