From f4a24d04adaa65bf67c5bce2ab7fcec0bb72c33d Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Mon, 19 Dec 2022 11:46:02 +0800 Subject: [PATCH] fix: fix the getValue of yaml 1. Fix the yaml value dump in the utils 2. Update the unit test Change-Id: I3c2120593ff533d38fdc7cb026d0d2d3bf1e7132 --- src/utils/yaml.js | 3 ++- src/utils/yaml.spec.js | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/utils/yaml.js b/src/utils/yaml.js index f38326dc..3ecd9fbc 100644 --- a/src/utils/yaml.js +++ b/src/utils/yaml.js @@ -18,8 +18,9 @@ import yaml from 'js-yaml'; export const getValue = (value) => { if (isObject(value)) { try { - return yaml.safeDump(value, { noRefs: true }); + return yaml.dump(value, { noRefs: true }); } catch (err) { + console.log('yaml-dump-err', err); return JSON.stringify(value, null, 2); } } diff --git a/src/utils/yaml.spec.js b/src/utils/yaml.spec.js index 7deaaa2e..61aa71d4 100644 --- a/src/utils/yaml.spec.js +++ b/src/utils/yaml.spec.js @@ -24,12 +24,9 @@ describe('test yaml', () => { }, }, }) - ).toBe(`{ - "level1": { - "level2": { - "key": "value" - } - } -}`); + ).toBe(`level1: + level2: + key: value +`); }); });