How to use the yamljs.parseFile 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 DragonsInn / BIRD3 / app / Support / GlobalConfig.js View on Github external
// Provide a full BIRD3 object that can be included by submodules.
var _root = require("find-root")(),
    path = require("path"),
    YAML = require("yamljs");

var BIRD3 = module.exports = {
    // The root of the app, one level above .../app
    root: _root,

    // NPM, Bower and Composer
    package: require(path.join(_root, "package.json")),
    composer: require(path.join(_root, "composer.json")),
    bower: require(path.join(_root, "bower.json")),

    // Loading the global BIRD3 config.
    config: YAML.parseFile(path.join(_root, "config/BIRD3.yml")),

    // Logger
    log: require("../Backend/Log"),

    // The key to share WebPack data on
    WebPackKey: "BIRD3.WebPack",

    // The session key-prefix used to track sessions
    sessionKey: "BIRD3.Session.",

    // The prefix used to retrive the hprose port.
    hprosePortKey: "BIRD3.hprosePort",

    // Max workers...
    maxWorkers: require("os").cpus().length
};
github NaturalIntelligence / Stubmatic / index.js View on Github external
function validateSyntax(fileName) {
	try {
		if (fileName.endsWith(".json")) {
			require('jsonlint').parse(fs.readFileSync(fileName, {
				encoding: 'utf-8'
			}));
			console.log("Validated successfully");
		} else if (fileName.endsWith(".yaml") || fileName.endsWith(".yml")) {
			require('yamljs').parseFile(fileName);
			console.log("Validated successfully");
		}else if(fileName.endsWith(".xml")){
			var result = require('fast-xml-parser').validate(fs.readFileSync(fileName, {
				encoding: 'utf-8'
			}));
			if(result === true) {
				console.log("Validated successfully");
			}else{
				console.log("Validation failed");
			}
		}else {
			console.log("Unsupported file");
		}
	} catch (e) {
		console.log("Validation failed");
		console.log(color(e, 'red'));
github NaturalIntelligence / Stubmatic / lib / loaders / MappingsBuilder.js View on Github external
buildMappings(mappingFiles, allMappings){
        var fileLevelMappings;
        allMappings = allMappings || [];
        //defaultConfig = config.mappings.default || defaultConfig;
        defaultConfig = deepAssign({},defaultConfig, this.options.mappings.default);
        
        for(var fileName in mappingFiles){
            var req_mapping = mappingFiles[fileName];
            try{
                fileLevelMappings = YAML.parseFile(req_mapping);
                if(!fileLevelMappings || fileLevelMappings.length === 0){
                    logger.info(req_mapping + " is an empty file.");
                }else{
                    logger.info("Loading "+ fileLevelMappings.length +" mappings from " + req_mapping);
    
                    let fileLevelMappingIndex = -1;
                    for(var i=0;i
github Alorel / ngforage / build / generate-changelog.js View on Github external
gulp.task('changelog', cb => {
  const YAML = require('yamljs');
  const reduce = require('lodash/reduce');
  const sortBy = require('lodash/sortBy');
  let parsed = YAML.parseFile('./CHANGELOG.yml');

  Object.keys(parsed)
    .sort()
    .reverse()
    .reduce(
      (acc, version) => {
        acc[version] = parsed[version];

        return acc;
      },
      {}
    );

  const versions = Object.keys(parsed);
  const numVersions = versions.length;
github node-muneem / muneem / src / routesManager.js View on Github external
RoutesManager.prototype.readRoutesFromFile = function(filepath){
    let routes;
    try{
        routes = YAML.parseFile(filepath);
    }catch(e){
        logger.log.error( filepath + " is an invalid Yaml file or have syntax issues.");
        logger.log.error( e);
    }
    logger.log.info("reading "+ (routes && routes.length) +" routes from file " + filepath);
    routes && this.addRoutes(routes);
}

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