|
3 | 3 |
|
4 | 4 | [](https://codeclimate.com/github/ExpCoderWeb/fullstack-javascript-project-46/maintainability) [](https://codeclimate.com/github/ExpCoderWeb/fullstack-javascript-project-46/test_coverage) |
5 | 5 |
|
| 6 | +### Overview |
| 7 | + |
| 8 | +**"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. |
| 9 | + |
| 10 | +**Utility features**: |
| 11 | + |
| 12 | +- Support for different input formats: JSON, YAML |
| 13 | +- Output in stylish (by default), plain text, and JSON format |
| 14 | + |
| 15 | +### Minimal system requirements: |
| 16 | +- Unix terminal |
| 17 | +- Node.js: version from 18.x |
| 18 | + |
| 19 | +### Utility setup |
| 20 | +1. Clone the repo with the following command: |
| 21 | +```bash |
| 22 | +git clone git@github.com:ExpCoderWeb/fullstack-javascript-project-46.git |
| 23 | +``` |
| 24 | +2. Enter the root directory of the package with the command: |
| 25 | +```bash |
| 26 | +cd fullstack-javascript-project-46 |
| 27 | +``` |
| 28 | +3. Install the necessary dependencies with the command: |
| 29 | +```bash |
| 30 | +npm ci |
| 31 | +``` |
| 32 | +4. Create a symbolic link to the package in order to make the utility to run from any directory of the system using the command: |
| 33 | +```bash |
| 34 | +npm link |
| 35 | +``` |
| 36 | + |
| 37 | +### Usage |
| 38 | +```bash |
| 39 | +Usage: gendiff [options] <filepath1> <filepath2> |
| 40 | + |
| 41 | +Compares two configuration files and shows a difference. |
| 42 | + |
| 43 | +Options: |
| 44 | + -V, --version output the version number |
| 45 | + -f, --format [type] output format (default: "stylish") |
| 46 | + -h, --help output usage information |
| 47 | +``` |
| 48 | +Program can handle both absolute and relative filepaths. Compared files can be in different formats. Example: |
| 49 | +```bash |
| 50 | +gendiff /home/user/__fixtures__/file1.json __fixtures__/file2.yml |
| 51 | +``` |
| 52 | + |
| 53 | +This library can be installed as a dependency in any other NPM package as well. An example of how other packages could use genDiff: |
| 54 | +```bash |
| 55 | +import genDiff from '@hexlet/code'; |
| 56 | + |
| 57 | +const diff = genDiff(filepath1, filepath2, formatName); |
| 58 | +console.log(diff); |
| 59 | +``` |
| 60 | + |
6 | 61 | ### Demonstration |
7 | 62 |
|
8 | | -#### 1. Comparison of flat files (JSON): |
9 | | -[](https://asciinema.org/a/P902Vkx6vLx3oAVjEOB3W8oor) |
| 63 | +#### 1. Comparison of flat files: |
| 64 | +[](https://asciinema.org/a/Tc8nH134MBp8TLBOkwke4eK1Y) |
| 65 | + |
| 66 | +#### 2. Comparison of nested files (format 'stylish'): |
| 67 | +[](https://asciinema.org/a/R2vd2AmfaKWZAhdZq5yholDQN) |
| 68 | + |
| 69 | +#### 3. Comparison of nested files (format 'plain'): |
| 70 | +[](https://asciinema.org/a/xreCxFS8BDQ7EHDaMP9c7WK0S) |
| 71 | + |
| 72 | +#### 4. Comparison of nested files (format 'json'): |
| 73 | +[](https://asciinema.org/a/GAoKHeauTxNIpUXpUUFXb2izu) |
0 commit comments