@travetto/yaml
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
@@ -29,4 +29,3 @@ { | ||
}, | ||
"version": "1.0.0-rc.1", | ||
"gitHead": "1aab475eaec81e90cc3a19fc7b68edb6510f8d23" | ||
} | ||
"version": "1.0.0-rc.2" | ||
} |
@@ -13,8 +13,11 @@ import { Util } from '@travetto/base'; | ||
static clean(key: string) { | ||
if (/['"@ -:]/.test(key)) { | ||
if (/[#'"@ \-:]/.test(key)) { | ||
return key.includes('"') ? | ||
`'${key.replace(/[']/g, '\\\'')}'` : | ||
`"${key.replace(/["]/g, '\\"')}"`; | ||
} else if (!key) { | ||
return `''`; | ||
} else { | ||
return key; | ||
} | ||
return key; | ||
} | ||
@@ -78,5 +81,9 @@ | ||
} else if (Array.isArray(o)) { | ||
out = o.map(el => `${prefix}-${this.serialize(el, indent, wordwrap, indentLevel + indent)}`).join('\n'); | ||
if (indentLevel > 0) { | ||
out = `\n${out}`; | ||
if (o.length) { | ||
out = o.map(el => `${prefix}-${this.serialize(el, indent, wordwrap, indentLevel + indent)}`).join('\n'); | ||
if (indentLevel > 0) { | ||
out = `\n${out}`; | ||
} | ||
} else { | ||
out = ` []`; | ||
} | ||
@@ -91,3 +98,3 @@ } else if (typeof o === 'number' || typeof o === 'boolean' || o === null) { | ||
} else { | ||
out = ` ${lines[0]}`; | ||
out = ` ${this.clean(lines[0])}`; | ||
} | ||
@@ -97,2 +104,3 @@ } else if (o !== undefined) { | ||
out = (Object.keys(fin) as (keyof typeof fin)[]) | ||
.filter(x => fin[x] !== undefined) | ||
.map(x => `${prefix}${this.clean(x)}:${this.serialize(fin[x], indent, wordwrap, indentLevel + indent)}`) | ||
@@ -99,0 +107,0 @@ .join('\n'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
650
21370
10