How to use the yamljs.load 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 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 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 datopian / data-cli / lib / utils / datahub.js View on Github external
async pushFlow(specPath){
    let spec = {}
    try {
      spec = YAML.load(specPath)
    } catch (err) {
      throw new Error(err.message)
    }

    this._debugMsg('Calling source upload with spec')
    this._debugMsg(spec)

    const token = await this._authz('source')
    const res = await this._fetch('/source/upload', token, {
      method: 'POST',
      body: spec
    })

    if (res.status === 200) {
      const out = await res.json()
      this._debugMsg(out)
github plotly / falcon / backend / persistent / Tags.js View on Github external
export function getTags() {
    if (fs.existsSync(getSetting('TAGS_PATH'))) {
        return YAML.load(getSetting('TAGS_PATH').toString());
    }
    return [];
}
github triplecanopy / b-ber / src / bber-lib / config.es6 View on Github external
fileOrDefaults(type) {
    const buildConfig = { src: this.config.src, dist: `${this.config.dist}-${type}`, pageList: [] }
    const fpath = path.join(cwd, this.config.src, `${type}.yml`)
    try {
      if (fs.statSync(fpath)) {
        Object.assign(buildConfig, { pageList: YAML.load(fpath) })
      }
    } catch (err) {
      return buildConfig
    }
    return buildConfig
  }
}
github zhuzhuyule / HexoEditor / views / main / hexo / plugins / renderer / yaml.js View on Github external
function yamlHelper(data) {
  return yaml.load(escapeYAML(data.text));
}
github atomist / sdm-pack-aspect / lib / routes / api.ts View on Github external
function exposeSwaggerDoc(express: Express, docRoute: string): void {
    const swaggerDocPath = path.join(__dirname, "..", "..", "swagger.yaml");
    const swaggerDocument = yaml.load(swaggerDocPath);
    express.use(docRoute, swaggerUi.serve, swaggerUi.setup(swaggerDocument));
}

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