Skip to content

Commit

Permalink
Fix 'yamlToJson.mjs'
Browse files Browse the repository at this point in the history
- Add missing process import
- Sort imports
- Replace 'prettier' by internal function
- Add console output
  • Loading branch information
KristjanESPERANTO committed Dec 30, 2024
1 parent 0d2e2f7 commit 2d28f1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------
Expand Down
17 changes: 9 additions & 8 deletions scripts/yamlToJson.mjs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 2d28f1c

Please sign in to comment.