How to use yamljs - 10 common examples

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 jverhoelen / fish-history-to-zsh / index.js View on Github external
/*
  Fish history (~/.local/share/fish/fish_history) is in YAML format.
  Parsed to JS object it looks like:

  [{
    cmd: './some-command',
    when: 123123123
  }, ...]


  Zsh history looks like:
  : 1482183081:0;git clone https://github.com/powerline/fonts.git
 */

const zshHistory = yamljs
  .load(getUserHome() + '/.local/share/fish/fish_history')
  .map(entry => `: ${entry.when}:0;${entry.cmd}`)
  .join('\n');


// log to stdout to append the converted fish history to ~/.zsh_history
console.log(zshHistory);
github svaarala / duktape / debugger / duk_debug.js View on Github external
var ERR_UNKNOWN = 0x00;
var ERR_UNSUPPORTED = 0x01;
var ERR_TOOMANY = 0x02;
var ERR_NOTFOUND = 0x03;

// Marker objects for special protocol values
var DVAL_EOM = { type: 'eom' };
var DVAL_REQ = { type: 'req' };
var DVAL_REP = { type: 'rep' };
var DVAL_ERR = { type: 'err' };
var DVAL_NFY = { type: 'nfy' };

// String map for commands (debug dumping).  A single map works (instead of
// separate maps for each direction) because command numbers don't currently
// overlap.  So merge the YAML metadata.
var debugCommandMeta = yaml.load('duk_debugcommands.yaml');
var debugCommandNames = [];  // list of command names, merged client/target
debugCommandMeta.target_commands.forEach(function (k, i) {
    debugCommandNames[i] = k;
});
debugCommandMeta.client_commands.forEach(function (k, i) {  // override
    debugCommandNames[i] = k;
});
var debugCommandNumbers = {};  // map from (merged) command name to number
debugCommandNames.forEach(function (k, i) {
    debugCommandNumbers[k] = i;
});

// Duktape heaphdr type constants, must match C headers
var DUK_HTYPE_STRING = 0;
var DUK_HTYPE_OBJECT = 1;
var DUK_HTYPE_BUFFER = 2;
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 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 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 netlify / netlify-cms / website / gulpfile.babel.js View on Github external
new Promise((resolve, reject) => {
            const contributors = JSON.parse(content).contributors.map(c => {
              const avatar = url.parse(c['avatar_url'], true);
              avatar.search = undefined; // Override so that we can use `avatar.query`.
              if (avatar.hostname.endsWith('githubusercontent.com')) {
                // Use 32px avatars, instead of full-size.
                avatar.query['s'] = '32';
              }
              const avatar_url = url.format(avatar);
              return Object.assign({}, c, { avatar_url });
            });
            resolve(yaml.dump({ contributors }));
          })
      )
github rkoval / alfred-aws-console-services-workflow / src / generate_items.js View on Github external
#!/usr/bin/env node

YAML = require('yamljs');
const consoleServices = YAML.load('console-services.yml');
const listItems = generate(consoleServices);
injectIntoXml(listItems);

function generate(consoleServices) {
  return consoleServices.map(({command, description, icon, url}) => {
    console.log(command);

    const consoleService = {
      title: command,
      arg: url,
      subtitle: description,
      imagefile: icon || `${command}.png`,
    };

    return consoleService;
  });
github LoeiFy / Mirror / bin / mirror.js View on Github external
.action(function() {
  const config = yaml.load(`${process.cwd()}/config.yml`)
  const html = fs.readFileSync(`${process.cwd()}/index.html`, 'utf-8')

  if (!config.title || !config.user || !config.repository || !config.perpage || !config.token) {
    return console.log('Configure infomation error')
  }

  const content = html.replace('$config', JSON.stringify(config))
  fs.outputFileSync(`${process.cwd()}/index.html`, content)

  console.log('Finished building the blog')
})
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 {};
  }

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