How to use the yaml.createNode function in yaml

To help you get started, we’ve selected a few yaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wordup-dev / wordup-cli / src / lib / project.js View on Github external
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})
    }

  }
github wordup-dev / wordup-cli / src / lib / project.js View on Github external
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})
    }

  }
github padloc / padloc / packages / locale / src / extract.ts View on Github external
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();
}