How to use the yamljs.stringify function in yamljs

To help you get started, we’ve selected a few yamljs 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 bezoerb / generator-sf / generators / backend / symfony / index.js View on Github external
dropAssetic: function () {
      if (!this._hasAssetic()) {
        return;
      }

      // Remove assetic from config_dev.yml
      const confDev = YAML.load('app/config/config_dev.yml');
      delete confDev.assetic;
      const newConfDev = YAML.stringify(confDev, 2, 4);
      fs.writeFileSync('app/config/config_dev.yml', newConfDev);

      // Remove assetic from config.yml
      const conf = YAML.load('app/config/config.yml');
      delete conf.assetic;

      const newConf = YAML.stringify(conf, 2, 4);
      fs.writeFileSync('app/config/config.yml', newConf);

      // Remove assetic from app kernel
      const appKernel = read('app/AppKernel.php').replace('new Symfony\\Bundle\\AsseticBundle\\AsseticBundle(),', '');
      fs.writeFileSync('app/AppKernel.php', appKernel);

      return this._composer(['remove', 'symfony/assetic-bundle']);
    },
github y12studio / dltdojo / lib / dltbuilder.js View on Github external
Dltbuilder.WriteFiles = function(title, dc, arr , path, name){
    var aliasHead = Dltbuilder.BuildAlias(name)
    var arrFinal = aliasHead.concat(arr)
    var peersStr = Dltbuilder.BuildHead(title, '\r\n') + YAML.stringify(dc, 6, 2)
    var shfunc=fs.readFileSync("lib/bashfunc.sh", "utf8");
    var aliasStr = Dltbuilder.BuildHead(title, '\r\n') + shfunc + '\n' + arrFinal.join('\n')
    fs.writeFileSync(`${path}/peers${name}.yml`, peersStr)
    var shfile = `${path}/alias${name}.sh`
    fs.writeFileSync(shfile, aliasStr)
}
github nest-cloud / nestcloud / packages / service / etcd-service.ts View on Github external
private async registerService() {
        const key = `service__${this.self.name}__${this.self.address}__${this.self.port}`;
        const ttl = get(this.options, 'healthCheck.ttl', 20);
        while (true) {
            try {
                const lease = this.client.namespace(this.namespace).lease(ttl);
                await lease.put(key).value(YAML.stringify(this.self));
                lease.on('lost', async () => {
                    lease.removeAllListeners('lost');
                    await sleep(5000);
                    await this.registerService();
                });

                this.logger.log('ServiceModule initialized');
                break;
            } catch (e) {
                this.logger.error(`Unable to initial ServiceModule, retrying...`, e);
                await sleep(this.options.retryInterval || 5000);
            }
        }
    }
github findhit / coreos / lib / core / cloud-config.js View on Github external
CloudConfig.prototype.toYAML = function () {
    debug( 'stringifying to YAML' );

    var yaml = YAML.stringify( this.toJSON(), Infinity, 4 );

    debug( 'yaml generated' );

    return "#cloud-config" + "\n" + yaml;
};
github soyuka / explorer / routes / admin.js View on Github external
return function(req, res, next) {
    if(!req.user.admin)
      return next(new HTTPError('Forbidden', 403))

    res.locals.config = config
    res.locals.ymlConfig = yaml.stringify(config, 2, 4) 

    return next()
  }
}
github SocketCluster / baasil-cli / bin / cli.js View on Github external
containersSocketCluster[index].env = containersSocketCluster[index].env.filter((envObject) => {
              return envObject.name != 'SOCKETCLUSTER_WORKERS' && envObject.name != 'SOCKETCLUSTER_BROKERS';
            });
            containersSocketCluster[index].env.push({
              name: 'SOCKETCLUSTER_WORKERS',
              value: String(configSocketCluster.workers || defaultWorkerCount)
            });
            containersSocketCluster[index].env.push({
              name: 'SOCKETCLUSTER_BROKERS',
              value: String(configSocketCluster.brokers || defaultBrokerCount)
            });
          }
        }
      });

      var formattedYAMLStringSocketCluster = sanitizeYAML(YAML.stringify(deploymentConfSocketCluster, Infinity, 2));
      fs.writeFileSync(kubeConfSocketCluster, formattedYAMLStringSocketCluster);

      var kubeConfSCCBroker = getSCCBrokerDeploymentDefPath(kubernetesDirPath);
      var kubeConfContentSCCBroker = fs.readFileSync(kubeConfSCCBroker, {encoding: 'utf8'});

      var deploymentConfSCCBroker = YAML.parse(kubeConfContentSCCBroker);
      var configSCCBroker = baasilConfig.sccBroker || {};

      var containersSCCBroker = deploymentConfSCCBroker.spec.template.spec.containers;

      containersSCCBroker.forEach((value, index) => {
        if (value) {
          if (value.name == 'scc-broker') {
            if (!containersSCCBroker[index].env) {
              containersSCCBroker[index].env = [];
            }
github nest-cloud / nestcloud / packages / config / consul-config.ts View on Github external
async set(path: string, value: any) {
        this.store.update(path, value);
        const yamlString = YAML.stringify(this.store.data);
        try {
            await this.consul.kv.set(this.key, yamlString);
        } catch (e) {
            throw new ConfigSyncException(e.message, e.stack);
        }
    }
github SunGard-Labs / fix2json / fix2json.js View on Github external
function processLine(line) {
    var targetObj = resolveFields(extractFields(line));
    if (yaml) {
        return YAML.stringify(targetObj, 256);
    } else {
        return pretty ? JSON.stringify(targetObj, undefined, 2) : JSON.stringify(targetObj)
    }
}
github BarstoolSports / serverless-micro / lib / build.js View on Github external
buildServiceYML(service_id, functions, stage) {
    let yamlString = YAML.stringify(this.getYAMLObject(this.serverless.service, service_id, functions, stage), 6, 2);
    return write(`./.services/${service_id}/serverless.yml`, yamlString);
  }
github lukeautry / tsoa / src / module / generate-swagger-spec.ts View on Github external
let spec: Swagger.Spec;
  if (swaggerConfig.specVersion && swaggerConfig.specVersion === 3) {
    spec = new SpecGenerator3(metadata, swaggerConfig).GetSpec();
  } else {
    spec = new SpecGenerator2(metadata, swaggerConfig).GetSpec();
  }

  const exists = await fsExists(swaggerConfig.outputDirectory);
  if (!exists) {
    await fsMkDir(swaggerConfig.outputDirectory);
  }

  let data = JSON.stringify(spec, null, '\t');
  if (swaggerConfig.yaml) {
    data = YAML.stringify(JSON.parse(data), 10);
  }
  const ext = swaggerConfig.yaml ? 'yaml' : 'json';

  await fsWriteFile(`${swaggerConfig.outputDirectory}/swagger.${ext}`, data, { encoding: 'utf8' });

  return metadata;
};

yamljs

Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

MIT
Latest version published 8 years ago

Package Health Score

64 / 100
Full package analysis