Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setWordupPkg(key, value) {
dotProp.set(this.dotWordupJson, key, value)
const newValue = dotProp.get(this.dotWordupJson, key)
const ymlLevels = key.split('.')
if(ymlLevels.length > 1){
this.dotWordupYml.setIn(ymlLevels, YAML.createNode(newValue))
}else{
this.dotWordupYml.set(key, YAML.createNode(newValue))
}
try {
fs.writeFileSync(this.getProjectPath('.wordup','config.yml'), this.dotWordupYml.toString())
} catch (err) {
this.error(err, {exit:1})
}
}
setWordupPkg(key, value) {
dotProp.set(this.dotWordupJson, key, value)
const newValue = dotProp.get(this.dotWordupJson, key)
const ymlLevels = key.split('.')
if(ymlLevels.length > 1){
this.dotWordupYml.setIn(ymlLevels, YAML.createNode(newValue))
}else{
this.dotWordupYml.set(key, YAML.createNode(newValue))
}
try {
fs.writeFileSync(this.getProjectPath('.wordup','config.yml'), this.dotWordupYml.toString())
} catch (err) {
this.error(err, {exit:1})
}
}
export function toYAML({ language, date, commit, items }: Translation) {
const doc = new YAML.Document();
doc.commentBefore = `
Padloc Translation File
language: ${language}
date: ${date.toISOString()}
commit: ${commit}
`;
doc.contents = YAML.createNode(items.flatMap(item => [item.original, item.translation])) as any;
for (const [i, item] of items.entries()) {
const node = (doc.contents as any).items[i * 2];
node.commentBefore = item.sources
.map(
({ file, line, character, comment }) => ` ${file}:${line},${character}${comment ? ` (${comment})` : ""}`
)
.join("\n");
(node as any).spaceBefore = true;
}
return doc.toString();
}