How to use the js-yaml.load 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 dreamerslab / coke / lib / assets / build.js View on Github external
module.exports = function ( current ){
  var source       = fs.readFileSync( current + 'config/assets.yml', 'utf8' );
  var config       = yaml.load( source );
  var version_path = current + 'public/assets_version.json';
  var tmp_dir      = current + 'tmp/assets/';

  lib.pub_dir = current + 'public/';

  var flow = new Flow({
    log    : true,
    minify : true,
    uglify : false
  });

  // check if the dir exist, if it does remove it
  flow.series( function ( args, next ){
    if( !fs.existsSync( tmp_dir )) return next();

    rmdir( tmp_dir, function ( err, dirs, files ){
github microsoft / vscode-cmake-tools / src / variant.ts View on Github external
if (await fs.exists(testpath)) {
          filepath = testpath;
          break;
        }
      }
    }

    let new_variants = this.loadVariantsFromSettings();
    // Check once more that we have a file to read
    if (filepath && await fs.exists(filepath)) {
      const content = (await fs.readFile(filepath)).toString();
      try {
        if (filepath.endsWith('.json')) {
          new_variants = json5.parse(content);
        } else {
          new_variants = yaml.load(content) as VarFileRoot;
        }
      } catch (e) { log.error(`Error parsing ${filepath}: ${e}`); }
    }

    const is_valid = validate(new_variants);
    if (!is_valid) {
      const errors = validate.errors as ajv.ErrorObject[];
      log.error('Invalid variants specified:');
      for (const err of errors) {
        log.error(` >> ${err.dataPath}: ${err.message}`);
      }
      new_variants = DEFAULT_VARIANTS;
      log.info('Loaded default variants');
    } else {
      log.info('Loaded new set of variants');
    }
github quasarframework / quasar-cli / lib / gulp / pipes / quasar-pipes.js View on Github external
additions = '',
      manifest = {}
      ;

    var pageName = path.basename(file.path).match(/^script\.(.*)\.js$/)[1];
    var pageFolder = path.resolve(path.dirname(file.path), '../');

    if (pageName !== pageFolder.substr(pageFolder.lastIndexOf('/') + 1)) {
      console.log('ERROR!!!!!!! wrongly named file!');
    }

    var originalPageFolder = path.resolve(pageFolder, '../../../src/pages/' + pageName);
    var yamlFile = originalPageFolder + '/config.' + pageName + '.yml';

    if (fs.existsSync(yamlFile)) {
      manifest = yaml.load(fs.readFileSync(yamlFile)) || {};
    }

    if (!manifest.css) {
      if (fs.existsSync(originalPageFolder + '/css/style.' + pageName + '.styl')) {
        manifest.css = 'pages/' + pageName + '/css/style.' + pageName + '.css';
      }
    }

    if (!manifest.html) {
      var htmlFile = originalPageFolder + '/html/view.' + pageName + '.html';

      if (fs.existsSync(htmlFile)) {
        additions += 'module.exports.config.html = require(\'raw!' + htmlFile + '\');';
      }
    }
github retextjs / retext-equality / script / generate.js View on Github external
.map(function(basename) {
      return yaml.load(String(fs.readFileSync(join(info.root, basename))))
    })
    .reduce(function(all, cur) {
github WriterLighter / WriterLighter-old / src / js / modules / lastedit.js View on Github external
return fs.readFile(lastEditPath, function(err, text) {
      if (err == null) {
        const data = YAML.load(text);
        const {novel:{name}, chapter: {number}} = data.opened;

        wl.novel.openNovel(name || "はじめよう");

        (number != null) && wl.novel.openChapter(number);

        return wl.editor.setDirection(data.status.direction);
      } else { return wl.novel.openNovel("はじめよう"); }
    });
  }
github RanvierMUD / core / src / DataManagement / AreaData.js View on Github external
loadRooms() {
    let roomsYaml;

    try {
      roomsYaml = fs.readFileSync(path.join(this.basePath, 'rooms.yml'));
    } catch (err) {
      return new Error('Error loading Rooms yaml');
    }

    this.rooms = yaml.load(roomsYaml);
  }
github zerobias / effector / tasks / hooks.js View on Github external
async() => {
      if (cliArgs.current.length < 1) return
      const argRaw = cliArgs.current[0]
      let body
      try {
        body = load(argRaw)
      } catch {
        return
      }
      if (typeof body !== 'object' || body === null) return
      cliArgs.current.splice(0, 1)
      for (const field in body) {
        //$todo
        setConfig(field, body[field])
      }
    },
    async() => {
github argoproj / argo-workflows / ui / src / app / shared / components / resource-submit.tsx View on Github external
this.readFile(e.target.files, (newResource: string) => {
                                                const resource: T = jsYaml.load(newResource);
                                                this.validate(resource);
                                                formikApi.setFieldValue('resource', resource);
                                                formikApi.setFieldValue('resourceString', jsYaml.dump(resource));
                                            });
                                        } catch (e) {
github dworthen / js-yaml-front-matter / src / index.js View on Github external
? options
        : undefined;

    let re = /^(-{3}(?:\n|\r)([\w\W]+?)(?:\n|\r)-{3})?([\w\W]*)*/
        , results = re.exec(text)
        , conf = {}
        , yamlOrJson;

    if ((yamlOrJson = results[2])) {
        if (yamlOrJson.charAt(0) === '{') {
            conf = JSON.parse(yamlOrJson);
        } else {
            if(loadSafe) {
                conf = jsYaml.safeLoad(yamlOrJson, passThroughOptions);
            } else {
                conf = jsYaml.load(yamlOrJson, passThroughOptions); 
            }
        }
    }

    conf[contentKeyName] = results[3] || '';

    return conf;
};
github Val-istar-Guo / mili / src / handlers / merge / merge-yaml.ts View on Github external
const mergeYaml: FileGenerator = async file => {
  let content = file.content

  const beginMatched = content.match(/^\s*/g)
  const beginBlank = beginMatched ? beginMatched[0] : ''

  const endMatched = content.match(/\s*$/g)
  const endBlank = endMatched ? endMatched[0] : ''
  let result = content

  if (!file.projectFileExisted) {
    try {
      content = yaml.load(file.content)
      result = yaml.dump(content).replace(/\s*$/, '')
    } catch (e) {
      throw new Error([
        'The template file and the project file failed to merge due to a json syntax error in the template file.',
        'The project file will be overwritten directly by the template file.',
        `path: ${file.templatePath}`,
      ].join('\n'))
    }
  } else {
    let projectContent = await file.getProjectContent()

    try {
      content = yaml.load(file.content)
    } catch (e) {
      throw new Error([
        'The template file and the project file failed to merge due to a json syntax error in the template file.',