Skip to content

Difference generator for flat/nested json/yaml/ini files CLI/Library

License

Notifications You must be signed in to change notification settings

gomez-git/backend-project-lvl2

Repository files navigation

Maintainability Test Coverage Known Vulnerabilities Actions Status Actions Status License: MIT

Annotation

This is my second JavaScript project based on Hexlet backend courses. I built a difference generator for json, yaml and ini files.

How to install

git clone git@github.com:gomez-git/backend-project-lvl2.git
cd backend-project-lvl2
make install
make test
gendiff -h

How to use

You can use it as a script in terminal or as a library in your JavaScript project. It supports json, yaml and ini files. You can format difference in three styles: stylish (default), plain and json. You can choose replacer: ' ' (default) or custom replacer and one of three sort orders: asc (default), desc and none.

In terminal:

Install dependencies with command make install in directory with my project.

$ gendiff -h
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 (choices: "plain", "json", default: "stylish")
  -r, --replacer <char>    output replacer (default: "    ")
  -s, --sort-order <type>  output sort (choices: "desc", "none", default: "asc")
  -h, --help               output usage information

In your project:

Install my package with:

npm install https://github.com/gomez-git/backend-project-lvl2

Try it in your project:

import genDiff from '@hexlet/code';

const diff = genDiff(filepath1, filepath2[, { format, replacer, sortOrder }]);
console.log(diff);

Preview of gendiff util

Installation process

asciicast

Compare files in stylish format

asciicast

Compare files in plain format

asciicast

Compare files in json format with custom replacer

asciicast

About

Difference generator for flat/nested json/yaml/ini files CLI/Library

Resources

License

Stars

Watchers

Forks