Add yaml parse+mutate+reserialize test
This commit is contained in:
parent
76f7658763
commit
a8b105bdec
3 changed files with 39 additions and 2 deletions
17
backend/package-lock.json
generated
17
backend/package-lock.json
generated
|
@ -2442,8 +2442,7 @@
|
|||
"lodash": {
|
||||
"version": "4.17.19",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
|
||||
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
|
||||
},
|
||||
"lodash.chunk": {
|
||||
"version": "4.2.0",
|
||||
|
@ -4612,6 +4611,11 @@
|
|||
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
|
||||
"dev": true
|
||||
},
|
||||
"yaml-js": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/yaml-js/-/yaml-js-0.2.3.tgz",
|
||||
"integrity": "sha512-6xUQtVKl1qcd0EXtTEzUDVJy9Ji1fYa47LtkDtYKlIjhibPE9knNPmoRyf6SGREFHlOAUyDe9OdYqRP4DuSi5Q=="
|
||||
},
|
||||
"yargonaut": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/yargonaut/-/yargonaut-1.1.4.tgz",
|
||||
|
@ -4685,6 +4689,15 @@
|
|||
"decamelize": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"yawn-yaml": {
|
||||
"version": "github:dragory/yawn-yaml#77ab3870ca53c4693002c4a41336e7476e7934ed",
|
||||
"from": "github:dragory/yawn-yaml#string-number-fix-build",
|
||||
"requires": {
|
||||
"js-yaml": "^3.4.2",
|
||||
"lodash": "^4.17.11",
|
||||
"yaml-js": "^0.2.3"
|
||||
}
|
||||
},
|
||||
"zlib-sync": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/zlib-sync/-/zlib-sync-0.1.7.tgz",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"private": true,
|
||||
"scripts": {
|
||||
"watch": "cross-env NODE_ENV=development tsc-watch --onSuccess \"node start-dev.js\"",
|
||||
"watch-yaml-parse-test": "cross-env NODE_ENV=development tsc-watch --onSuccess \"node dist/backend/src/yamlParseTest.js\"",
|
||||
"build": "rimraf dist && tsc",
|
||||
"start-bot-dev": "cross-env NODE_ENV=development node -r ./register-tsconfig-paths.js --unhandled-rejections=strict --inspect=127.0.0.1:9229 dist/backend/src/index.js",
|
||||
"start-bot-prod": "cross-env NODE_ENV=production node -r ./register-tsconfig-paths.js --unhandled-rejections=strict dist/backend/src/index.js",
|
||||
|
@ -66,6 +67,7 @@
|
|||
"twemoji": "^12.1.4",
|
||||
"typeorm": "^0.2.14",
|
||||
"uuid": "^3.3.2",
|
||||
"yawn-yaml": "github:dragory/yawn-yaml#string-number-fix-build",
|
||||
"zlib-sync": "^0.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
22
backend/src/yamlParseTest.ts
Normal file
22
backend/src/yamlParseTest.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import YAML from "yawn-yaml/cjs";
|
||||
import { load } from "js-yaml";
|
||||
|
||||
const src = `
|
||||
prefix: '!'
|
||||
|
||||
plugins:
|
||||
myplugin:
|
||||
config:
|
||||
|
||||
can_do_thing: true
|
||||
|
||||
# Lol
|
||||
can_do_other_thing: false
|
||||
`;
|
||||
|
||||
const json = load(src);
|
||||
const yaml = new YAML(src);
|
||||
json.plugins.myplugin.config.can_do_thing = false;
|
||||
yaml.json = json;
|
||||
|
||||
console.log(yaml.yaml);
|
Loading…
Add table
Reference in a new issue