From 2d28f1cc8b8a3e2eeb79ddff3a669258dcb6d463 Mon Sep 17 00:00:00 2001 From: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Date: Mon, 30 Dec 2024 19:47:08 +0100 Subject: [PATCH] Fix 'yamlToJson.mjs' - Add missing process import - Sort imports - Replace 'prettier' by internal function - Add console output --- CHANGELOG.rst | 2 +- scripts/yamlToJson.mjs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e4beee39..c7efe57b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -191,7 +191,7 @@ Fixed ~~~~~ * JOSM remote control was not working because it was trying to be accessed as https://localhost:8111/. Switch to HTTP. - +* Fix `yamlToJson.mjs` v3.8.0_ - 2022-05-18 -------------------- diff --git a/scripts/yamlToJson.mjs b/scripts/yamlToJson.mjs index 045c83d7..b20fdadf 100644 --- a/scripts/yamlToJson.mjs +++ b/scripts/yamlToJson.mjs @@ -1,15 +1,16 @@ // Node script used to convert a .yaml file to a .json file // Call yamlToJson.mjs [input] [output] -const [, , input, output] = process.argv; -const out = output | `${input.split(".")[0]}.json`; +import process from "node:process"; +import { readFileSync, writeFileSync } from "node:fs"; import jsYaml from "js-yaml"; -import { readFileSync, writeFileSync } from "fs"; -import prettier from "prettier"; +const [, , input, output] = process.argv; +const out = output || `${input.split(".")[0]}.json`; + +console.log(`Converting ${input} to ${out}`); const loadedYaml = jsYaml.load(readFileSync(input, { encoding: "utf-8" })); -writeFileSync( - out, - prettier.format(JSON.stringify(loadedYaml), { parser: "json" }) -); +const jsonOutput = JSON.stringify(loadedYaml, null, 2); + +writeFileSync(out, jsonOutput);