Skip to content

ExpCoderWeb/fullstack-javascript-project-46

Repository files navigation

Hexlet tests and linter status:

Actions Status lint-and-test

Maintainability Test Coverage

Overview

"Difference Finder" is a program that determines the difference between two data structures. It displays how the second file has changed compared to the first one. This is a common task for which there are numerous online services, for example, http://www.jsondiff.com/. This mechanism is used when outputting tests or tracking changes in configuration files.

Utility features:

  • Support for different input formats: JSON, YAML
  • Output in stylish (by default), plain text, and JSON format

Minimal system requirements:

  • Unix terminal
  • Node.js: version from 18.x

Utility setup

  1. Clone the repo with the following command:
git clone git@github.com:ExpCoderWeb/fullstack-javascript-project-46.git
  1. Enter the root directory of the package with the command:
cd fullstack-javascript-project-46
  1. Install the necessary dependencies with the command:
npm ci
  1. Create a symbolic link to the package in order to make the utility to run from any directory of the system using the command:
npm link

Usage

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

Program can handle both absolute and relative filepaths. Compared files can be in different formats. Example:

gendiff /home/user/__fixtures__/file1.json __fixtures__/file2.yml

This library can be installed as a dependency in any other NPM package as well. An example of how other packages could use genDiff:

import genDiff from '@hexlet/code';

const diff = genDiff(filepath1, filepath2, formatName);
console.log(diff);

Demonstration

1. Comparison of flat files:

asciicast

2. Comparison of nested files (format 'stylish'):

asciicast

3. Comparison of nested files (format 'plain'):

asciicast

4. Comparison of nested files (format 'json'):

asciicast

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published