How to use the json.collective function in json

To help you get started, we’ve selected a few json 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 WebReflection / lightercollective / index.js View on Github external
#!/usr/bin/env node
// (C) Andrea Giammarchi - @WebReflection (ISC)
var path = require('path');

try {
  var json = path.resolve('./package.json');
  var package = require(json);
  // be sure collective is there and refers to lightercollective
  var collective = (
    (package.dependencies || {}).lightercollective ||
    (package.devDependencies || {}).lightercollective
  ) && package.collective;
  if (
    !collective ||
    -1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) ||
    /^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE)
  ) {
    throw 0;
  }
  if (collective.logo) {
    if (/^(https?):/.test(collective.logo))
      require(RegExp.$1)
        .get(collective.logo, function (response) {
          if (response.statusCode === 200) {
            response.setEncoding('utf8');
            var data = [];
            response.on('data', function (chunk) { data.push(chunk); });
            response.on('end', function () { showLogo(data.join('')) });