-
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
9 changed files
with
74 additions
and
21 deletions.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
install: | ||
npm ci | ||
|
||
gen-diff: | ||
node bin/brain-games.js | ||
|
||
publish: | ||
npm publish --dry-run | ||
|
||
link: | ||
npm link |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
import app from '../genDiff.js'; | ||
import app from '../src/index.js'; | ||
|
||
app(); |
This file was deleted.
Oops, something went wrong.
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
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,35 @@ | ||
import path from 'path'; | ||
import { program } from 'commander'; | ||
|
||
import { parseFile } from './utils/index.js'; | ||
|
||
const app = () => { | ||
program | ||
.name('genDiff') | ||
.description('Compares two configuration files and shows a difference.') | ||
.version('1.0.0') | ||
.helpOption('-h, --help', 'output usage information') | ||
.option('-f, --format [type]', 'output format') | ||
.arguments('<filepath1> <filepath2>') | ||
.action((filepath1, filepath2) => { | ||
const absolutePath1 = path.resolve(process.cwd(), filepath1); | ||
const absolutePath2 = path.resolve(process.cwd(), filepath2); | ||
|
||
console.log(222, absolutePath1); | ||
console.log(333, absolutePath2); | ||
|
||
const data1 = parseFile(absolutePath1); | ||
const data2 = parseFile(absolutePath2); | ||
|
||
console.log('data1: ', data1); | ||
console.log('data2: ', data2); | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
// const options = program.opts(); | ||
// console.log(options); | ||
// console.log(process.argv); | ||
}; | ||
|
||
export default app; |
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 @@ | ||
export { default as parseFile } from './parseFile.js'; |
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,14 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export default (filePath) => { | ||
const fileContent = fs.readFileSync(filePath, 'utf-8'); | ||
const extension = path.extname(filePath); | ||
|
||
switch (extension) { | ||
case '.json': | ||
return JSON.parse(fileContent); | ||
default: | ||
throw new Error(`Unsupported file format: ${extension}`); | ||
} | ||
}; |