Skip to content

Commit

Permalink
fix: Remove refs in yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Feb 17, 2020
1 parent da02d5e commit a9a9013
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import yaml from 'js-yaml/dist/js-yaml'
export const getValue = (mode, value) => {
if (isObject(value)) {
try {
return mode === 'yaml' ? yaml.safeDump(value) : ''
return mode === 'yaml' ? yaml.safeDump(value, { noRefs: true }) : ''
} catch (err) {
console.error(err)
return JSON.stringify(value, null, 2)
Expand All @@ -44,9 +44,13 @@ export const getAllYAMLValue = value => {
const objs = []

try {
yaml.safeLoadAll(value, obj => {
objs.push(obj)
})
yaml.safeLoadAll(
value,
obj => {
objs.push(obj)
},
{ noRefs: true }
)
} catch (err) {}

return objs
Expand Down

0 comments on commit a9a9013

Please sign in to comment.