update to remove un-needed replace

This commit is contained in:
depperm 2025-02-16 15:16:33 -05:00
parent 73c979b7aa
commit 01e4f9bb2f
3 changed files with 4 additions and 4 deletions

2
package-lock.json generated
View file

@ -96,7 +96,7 @@
"vkbeautify": "^0.99.3", "vkbeautify": "^0.99.3",
"xpath": "0.0.34", "xpath": "0.0.34",
"xregexp": "^5.1.1", "xregexp": "^5.1.1",
"yaml": "^2.2.1", "yaml": "^2.7.0",
"zlibjs": "^0.3.1" "zlibjs": "^0.3.1"
}, },
"devDependencies": { "devDependencies": {

View file

@ -181,7 +181,7 @@
"vkbeautify": "^0.99.3", "vkbeautify": "^0.99.3",
"xpath": "0.0.34", "xpath": "0.0.34",
"xregexp": "^5.1.1", "xregexp": "^5.1.1",
"yaml": "^2.2.1", "yaml": "^2.7.0",
"zlibjs": "^0.3.1" "zlibjs": "^0.3.1"
}, },
"scripts": { "scripts": {

View file

@ -36,8 +36,8 @@ class JSONToYAML extends Operation {
run(input, args) { run(input, args) {
const doc = new YAML.Document(); const doc = new YAML.Document();
try { try {
doc.contents = JSON.parse(input.replace(/(\w+):/gm, `"$1":`)); doc.contents = YAML.stringify(JSON.parse(input));
return doc.toString(); return doc.toString().replace(/^\|\n/, "");
} catch (err) { } catch (err) {
throw new OperationError("Unable to parse JSON to YAML: " + err.toString()); throw new OperationError("Unable to parse JSON to YAML: " + err.toString());
} }