How to use the yamljs.parse 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 mcollina / autocannon-ci / autocannon-ci.js View on Github external
config: path.resolve('autocannon.yml'),
      flamegraph: false
    }
  })

  if (!hasFile(args.config)) {
    help.toStdout()
    return
  }

  // should never throw, we have just
  // checked if we can access this
  const data = fs.readFileSync(args.config, 'utf8')

  try {
    var config = YAML.parse(data)
  } catch (err) {
    console.error(err)
    process.exit(1)
  }

  var exec = nodePath

  if (args.flamegraph) {
    if (isWin) {
      console.error('flamegraphs are supported only on Linux and Mac OS X')
      process.exit(1)
    }

    exec = zeroX
    config.server = '--svg ' + config.server
  }
github sholladay / os-proxy / index.js View on Github external
const get = async (input) => {
    const option = Object.assign({}, input);
    option.device = option.device || await getDevice();
    const config = joi.attempt(option, joi.object({
        device   : joi.string().required()
    }).required());

    const output = await manage.get(config.device);

    if (!output) {
        throw new TypeError(`Unable to get proxy configuration. No output to parse.`);
    }

    const parsed = yaml.parse(output);

    // OS X answers with less than ideal property names.
    // We normalize them here before anyone sees it.
    return {
        hostname : parsed.Server,
        port     : parsed.Port,
        enabled  : isOn(parsed.Enabled)
    };
};
github meanie / angular-seed / build / utils / load-config.js View on Github external
function loadEnvConfig(env) {
  try {
    let configPath = path.join(CONFIG_PATH, env + '.yml');
    let configYaml = fs.readFileSync(configPath).toString();
    return YAML.parse(configYaml);
  }
  catch (e) {
    if (env === 'development') {
      return loadEnvConfig('dev');
    }
    if (env === 'production') {
      return loadEnvConfig('production');
    }
    if (env !== 'local') {
      console.warn(
        chalk.yellow('Could not load environment configuration file'),
        chalk.magenta(env + '.yml')
      );
    }
    return {};
  }
github electrode-io / fyn / cli / load-rc.js View on Github external
function readRc(fname) {
  const rcFname = Path.basename(fname);

  try {
    const rcData = Fs.readFileSync(fname).toString();
    let rc;

    try {
      assert(rcFname === ".fynrc" && rcData.startsWith("---"));
      rc = Yaml.parse(rcData);
      logger.debug(`Loaded ${rcFname} YAML RC`, fname, JSON.stringify(rc));
    } catch (e) {
      rc = Ini.parse(rcData);
      logger.debug(`Loaded ${rcFname} ini RC`, fname, JSON.stringify(rc));
    }

    return rc;
  } catch (e) {
    if (e.code !== "ENOENT") {
      logger.error(`Failed to process ${rcFname} RC file`, fname, e.message);
    }
    return {};
  }
}
github serverless / enterprise-plugin / src / lib / safeguards / index.js View on Github external
.map(async (filename) => {
        const content = await readFile(path.join(artifactsPath, filename))
        try {
          if (filename.match(/\.json$/i)) {
            return [filename, JSON.parse(content)]
          }
          return [filename, yml.parse(content)]
        } catch (error) {
          ctx.sls.cli.log(
            `(Safeguards) Failed to parse file ${filename} in the artifacts directory.`,
            `Serverless Enterprise`
          )
          throw error
        }
      })
  )
github DecentCMS / DecentCMS / modules / core / content / services / json-yaml-md-file-parser.js View on Github external
parse: function parseJsonYamlMarkdown(context, nextParser) {
    var YAML = require('yamljs');
    var filePath = context.path;
    var ext = filePath.substr(-5);
    var data = context.data;
    var item = ext === '.json'
      ? JSON.parse(data)
      : ext === '.yaml'
      ? YAML.parse(data)
      : filePath.substr(-8) === '.yaml.md'
      ? parseYamlMarkdown(data)
      : null;
    if (item) {
      context.item = Object.assign(context.item || {}, item);
    }
    nextParser();
  }
};
github arjun-g / vs-swagger-viewer / extension.js View on Github external
function GetParsedFile(fileName, document) {
    var fileContent = document.getText();
    if (document.languageId === "json") {
        return JSON.parse(fileContent);
    } else if (document.languageId === "yaml") {
        return YAML.parse(fileContent);
    } else if (document.languageId === "plaintext") {
        if (fileContent.match(/^\s*[{[]/)) {
            return JSON.parse(fileContent);
        } else {
            return YAML.parse(fileContent);
        }
    }
}
github auth0 / cosmos / internal / docs / component / page.js View on Github external
code: markdownProps => {
        const language = markdownProps.className

        if (!language) return <code>{markdownProps.children}</code>
        else if (['lang-js', 'lang-jsx'].includes(language)) {
          return (
            <div>
              
            </div>
          )
        } else if (language === 'lang-meta') {
          const metadata = yaml.parse(markdownProps.children)
          return 
        } else {
          return null
        }
      },
      Alert,
github marvinroger / homie-server / lib / servers / ota.js View on Github external
async _loadManifest () {
    try {
      let rawManifest = await fs.readFileAsync(this.manifestPath);
      let manifest = YAML.parse(rawManifest.toString());
      let valid = await dataValidator.validateOtaManifest(manifest, this.dataDir);
      if (!valid) {
        return null;
      }

      return manifest;
    } catch (err) {
      log.error('OTA manifest cannot be parsed');
      return null;
    }
  }
github airtap / airtap / bin / airtap.js View on Github external
function readYAMLConfig (filename) {
  return yaml.parse(fs.readFileSync(filename, 'utf-8'))
}

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 7 years ago

Package Health Score

64 / 100
Full package analysis