Merge "fix: fix the getValue of yaml"

This commit is contained in:
Zuul 2023-01-06 12:54:00 +00:00 committed by Gerrit Code Review
commit e678f9c92b
2 changed files with 6 additions and 8 deletions

View File

@ -18,8 +18,9 @@ import yaml from 'js-yaml';
export const getValue = (value) => { export const getValue = (value) => {
if (isObject(value)) { if (isObject(value)) {
try { try {
return yaml.safeDump(value, { noRefs: true }); return yaml.dump(value, { noRefs: true });
} catch (err) { } catch (err) {
console.log('yaml-dump-err', err);
return JSON.stringify(value, null, 2); return JSON.stringify(value, null, 2);
} }
} }

View File

@ -24,12 +24,9 @@ describe('test yaml', () => {
}, },
}, },
}) })
).toBe(`{ ).toBe(`level1:
"level1": { level2:
"level2": { key: value
"key": "value" `);
}
}
}`);
}); });
}); });