"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
- Unix terminal
- Node.js: version from 18.x
- Clone the repo with the following command:
git clone git@github.com:ExpCoderWeb/fullstack-javascript-project-46.git- Enter the root directory of the package with the command:
cd fullstack-javascript-project-46- Install the necessary dependencies with the command:
npm ci- 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 linkUsage: 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 informationProgram can handle both absolute and relative filepaths. Compared files can be in different formats. Example:
gendiff /home/user/__fixtures__/file1.json __fixtures__/file2.ymlThis 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);