Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "jscmp", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Compare two JSON/JS files to find the diff between their exported objects", | ||
@@ -24,3 +24,4 @@ "author": "Ayush Gupta <AyushG3112@gmail.com>", | ||
"arg": "^4.1.3", | ||
"esm": "^3.2.25" | ||
"esm": "^3.2.25", | ||
"json2csv": "^4.5.4" | ||
}, | ||
@@ -27,0 +28,0 @@ "devDependencies": {}, |
# jscmp | ||
Compare two JSON/JS files to find the diff between their exported objects | ||
Compare two JSON/JS files to find the diff between their exported objects | ||
## Usage | ||
To install | ||
``` console | ||
npm i -g jscmp | ||
``` | ||
To Use: | ||
``` console | ||
jscmp /path/to/fileA /path/to/fileB [--mode=json|csv --out-file=/path/to/out-file] [-q] [--esm] | ||
``` |
@@ -59,2 +59,2 @@ import arg from "arg"; | ||
export default new CommandLineArguments().build(process.argv); | ||
export default new CommandLineArguments(); |
@@ -6,3 +6,3 @@ require = require("esm")(module /*, options*/); | ||
export function cli(args) { | ||
export async function cli(args) { | ||
const cliArgs = argumentParser.build(args); | ||
@@ -12,3 +12,3 @@ const errors = cliArgs.validate(); | ||
const result = process(...cliArgs.args.files, cliArgs); | ||
getHandler(cliArgs).handle(result); | ||
await (getHandler(cliArgs.args).handle(result)); | ||
} else { | ||
@@ -15,0 +15,0 @@ throw new Error(errors[0]); |
@@ -7,2 +7,9 @@ class DefaultHandler { | ||
handle(input = []) { | ||
if (!input.length) { | ||
return; | ||
} | ||
if (input.length) { | ||
console.log(`fileA: ${input[0].fileA}`); | ||
console.log(`fileB: ${input[0].fileB}\n`); | ||
} | ||
for (let item of input) { | ||
@@ -9,0 +16,0 @@ switch (item.type) { |
import DefaultHandler from "./defaultHandler"; | ||
import JSONHandler from "./jsonHandler"; | ||
import CSVHandler from "./csvHandler"; | ||
export default function getHandler(options = {}) { | ||
return new DefaultHandler(options); | ||
switch (options.mode) { | ||
case "json": | ||
return new JSONHandler(options); | ||
case "csv": | ||
return new CSVHandler(options); | ||
default: | ||
return new DefaultHandler(options); | ||
} | ||
} |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7686
17
232
17
3
3
+ Addedjson2csv@^4.5.4
+ Addedcommander@2.20.3(transitive)
+ Addedjson2csv@4.5.4(transitive)
+ Addedjsonparse@1.3.1(transitive)
+ Addedlodash.get@4.4.2(transitive)