-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
#!/usr/bin/env node | ||
import { Command } from 'commander'; | ||
import * as path from 'node:path'; | ||
import { cwd } from 'node:process'; | ||
import { readFileSync } from 'node:fs'; | ||
import fileParse from '../src/fileParse.js'; | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.name('gendiff') | ||
.description('Compares two configuration files and shows a difference.') | ||
.version('1.0.0'); | ||
.version('1.0.0') | ||
.arguments('<filepath1> <filepath2>') | ||
.option('-f, --format [type]', 'output format') | ||
.action((filepath1, filepath2) => { | ||
const absolutePath1 = path.resolve(cwd(), filepath1); | ||
const absolutePath2 = path.resolve(cwd(), filepath2); | ||
|
||
const file1Content = readFileSync(absolutePath1); | ||
const file2Content = readFileSync(absolutePath2); | ||
|
||
const file1Parsed = fileParse(file1Content); | ||
const file2Parsed = fileParse(file2Content); | ||
|
||
console.log(file1Parsed); | ||
console.log(file2Parsed); | ||
}); | ||
|
||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"host": "hexlet.io", | ||
"timeout": 50, | ||
"proxy": "123.234.53.22", | ||
"follow": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"timeout": 20, | ||
"verbose": true, | ||
"host": "hexlet.io" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const fileParse = (file) => JSON.parse(file); | ||
|
||
export default fileParse; |