From b90e1970bb7f9b9279328763de2514a558c2d4ed Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 27 Jul 2022 09:47:10 +0200 Subject: [PATCH] Add json merge script --- scripts/mergeJsonFiles.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/mergeJsonFiles.ts diff --git a/scripts/mergeJsonFiles.ts b/scripts/mergeJsonFiles.ts new file mode 100644 index 000000000..082d45386 --- /dev/null +++ b/scripts/mergeJsonFiles.ts @@ -0,0 +1,20 @@ +import {readFileSync, writeFileSync} from "fs"; +import {Utils} from "../Utils"; + +function main(args: string[]) { + + console.log("File Merge") + + if (args.length != 3) { + console.log("Usage: input1.json input2.json output.json") + console.log("You passed in the arguments: " + args.join(",")) + return + } + const [input1, input2, output] = args + const f1 = JSON.parse(readFileSync(input1, "utf8")) + const f2 = JSON.parse(readFileSync(input2, "utf8")) + Utils.Merge(f1, f2) + writeFileSync(output, JSON.stringify(f2, null, " ")) +} + +main(process.argv.slice(2)) \ No newline at end of file