Difference generator is a cli program. It compares two configuration files and shows a difference. Command-line utility for comparing differences between two data structures (JSON or YAML format files).
- Practice of test-driven development (TDD), writing automated tests for the project using Jest
- Integration of third-party libraries to solve various tasks
- Implementation of package's ability to work as a library
- Working with higher-order functions
- Building internal representation for tree-like structures
- Recursive traversal of tree-like structures
- Hierarchical design, identifying the right abstractions, moving side effects to the top level.
Technology Stack: JavaScript, Node.js, ESLint, GitHub Actions (CI), Jest, Lodash, commander.js
- Support for different input formats: yaml, json.
- Report generation as plain text, stylish and json.
# stylish format
gendiff ./__fixtures__/file1.json ./__fixtures__/file2.json
{
+ follow: false
setting1: Value 1
- setting2: 200
- setting3: true
+ setting3: {
key: value
}
+ setting4: blah blah
+ setting5: {
key5: value5
}
}
# plain format
gendiff -f plain ./__fixtures__/file1.json ./__fixtures__/file2.json
Property 'common.follow' was added with value: false
Property 'group1.baz' was updated. From 'bas' to 'bars'
Property 'group2' was removed
git@github.com:Lena05k/frontend-project-lvl2.git
make install
make link
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
-h, --help output usage information
gendiff filepath1 filepath2
gendiff
- quick command to compare a file.filepath1
- the path to the first file you want to compare.
Specify the directory: ./__fixtures__/file1.json
, ./__fixtures__/file1.yml
filepath2
- the path to the second file to be compared with.
Specify the directory: ./__fixtures__/file2.json
, ./__fixtures__/file1.yml
Example: gendiff ./__fixtures__/file1.json ./__fixtures__/file2.json
Difference generator after implementation returns the difference in one of the three styles.
'stylish'
- when the comparison is made line by line and all the differences between the first file and the second will be marked with "+" or "-".'plain'
- a text description of the attributes in the format of what was added/changed/deleted and where.'json'
- translation of the difference between files in JSON format.
By default, the output style is 'stylish', so the two call options listed below are equivalent:
gendiff ./__fixtures__/file1.json ./__fixtures__/file2.json
gendiff -f stylish ./__fixtures__/file1.json ./__fixtures__/file2.json
Output in 'plain' format:
gendiff -f plain ./__fixtures__/file1.json ./__fixtures__/file2.json
Output in 'json' format:
gendiff -f json ./__fixtures__/file1.json ./__fixtures__/file2.json
- Run linter:
make lint
- Run test:
make test
- Get test coverage:
make test-coverage