How to use the js-yaml.dump function in js-yaml

To help you get started, we’ve selected a few js-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 microsoft / pai / rest-server / src / models / template.js View on Github external
const save = function(options, callback) {
  let type = options.type;
  let name = options.name;
  let template = options.template;
  let pat = options.pat;
  try {
    let client = getAuthenticatedClient(pat);
    let b64text = base64.encode(yaml.dump(template));
    client.repos.createFile({
      owner: config.owner,
      repo: config.repository,
      path: `${type}/${name}.yaml`,
      message: 'Create template from PAI Marketplace.',
      content: b64text,
    }, function(err, res) {
      if (err) {
        // Maybe existed, try to update
        update({
          type: type,
          name: name,
          b64text: b64text,
          client: client,
        }, callback);
      } else {
github node-red / node-red / nodes / core / parsers / 70-YAML.js View on Github external
this.on("input", function(msg) {
            var value = RED.util.getMessageProperty(msg,node.property);
            if (value !== undefined) {
                if (typeof value === "string") {
                    try {
                        value = yaml.load(value);
                        RED.util.setMessageProperty(msg,node.property,value);
                        node.send(msg);
                    }
                    catch(e) { node.error(e.message,msg); }
                }
                else if (typeof value === "object") {
                    if (!Buffer.isBuffer(value)) {
                        try {
                            value = yaml.dump(value);
                            RED.util.setMessageProperty(msg,node.property,value);
                            node.send(msg);
                        }
                        catch(e) {
                            node.error(RED._("yaml.errors.dropped-error"));
                        }
                    }
                    else { node.warn(RED._("yaml.errors.dropped-object")); }
                }
                else { node.warn(RED._("yaml.errors.dropped")); }
            }
            else { node.send(msg); } // If no payload - just pass it on.
        });
    }
github ExpressGateway / express-gateway / test / common / gateway.helper.js View on Github external
module.exports.setYmlConfig = function ({ ymlConfigPath, newConfig }) {
  fs.writeFileSync(ymlConfigPath, yaml.dump(newConfig));
};
github jolicode / generator-joli-symfony / app / index.js View on Github external
cleanConfig: function () {
      if (this.symfonyWithAssetic) {
        var confDev = yaml.safeLoad(fs.readFileSync('app/config/config_dev.yml'));
        delete confDev.assetic;
        var newConfDev = yaml.dump(confDev, {indent: 4});
        fs.writeFileSync('app/config/config_dev.yml', newConfDev);

        var conf = yaml.safeLoad(fs.readFileSync('app/config/config.yml'));
        delete conf.assetic;
        var newConf = yaml.dump(conf, {indent: 4});
        fs.writeFileSync('app/config/config.yml', newConf);
      }
    },
github Qihoo360 / wayne / src / frontend / src / app / shared / diff / diff.component.ts View on Github external
createHtml() {
    let oldstr: string, newStr: string;
    try {
      if (this.inputType === 'json') {
        oldstr = this.formatString(this.diffTpl.oldStr);
        newStr = this.formatString(this.diffTpl.newStr);
      } else {
        oldstr = YAML.dump(this.formatJson(this.diffTpl.oldStr));
        newStr = YAML.dump(this.formatJson(this.diffTpl.newStr));
      }
    } catch {
      oldstr = '';
      newStr = '';
      this.messageService.showError('SHARED.DIFF.CHECK_DATA');
    }
    try {
      const dd = createPatch(
        this.diffTpl.fileName,
        oldstr,
        newStr,
        this.diffTpl.newHeader,
        this.diffTpl.oldHeader
      );
      const outStr = Diff2Html.getJsonFromDiff(
github DiscreetAI / dashboard-api / dashboard-api / postsetup.js View on Github external
const saveServerlessYml = (config) => {
  /*
  When dumping to yml, it puts quotation marks around Serverless variables. This
  breaks variable resolution, so I clean it out after dumping to yml but before
  writing to the config file.
  */
  const dumped = YAML.dump(config);
  const cleaned = dumped.replace("\'${self:provider.stage}\'", "${self:provider.stage}")
  fs.writeFileSync('serverless.yml', cleaned);
}
github serverless / serverless-azure-functions / src / services / funcService.ts View on Github external
private updateFunctionsYml(functionYml: any) {
    const serverlessYml = this.getServerlessYml();
    serverlessYml["functions"] = functionYml;
    this.serverless.utils.writeFileSync(
      this.configService.getConfigFile(),
      yaml.dump(serverlessYml)
    );
  }
github kubernetes / dashboard / src / app / frontend / common / dialogs / editresource / dialog.ts View on Github external
private updateText(): void {
    if (this.selectedMode === EditorMode.YAML) {
      this.text = toYaml(JSON.parse(this.text));
    } else {
      this.text = this.toRawJSON(fromYaml(this.text));
    }
  }
github G-Research / armada / internal / lookout / ui / src / services / JobService.ts View on Github external
function jobJsonToYaml(jobJson: string): string {
  return yaml.dump(JSON.parse(jobJson))
}
github chaos-mesh / chaos-mesh / ui / src / pages / ExperimentDetail / index.tsx View on Github external
<div>
          
            {detail &amp;&amp; configOpen &amp;&amp; (
              
                
                  
                    <button size="small" color="primary">
                      {T('common.update')}
                    </button>
                  
                
                
                  
                
              
            )}
          
        </div>
      

      {loading &amp;&amp; }
    
  )
}