How to use read-package-json - 10 common examples

To help you get started, we’ve selected a few read-package-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 ShieldBattery / ShieldBattery / deps / node / deps / npm / lib / unbuild.js View on Github external
readJson(path.resolve(folder, "package.json"), function (er, pkg) {
    // if no json, then just trash it, but no scripts or whatever.
    if (er) return rm(folder, cb)
    readJson.cache.del(folder)
    chain
      ( [ [lifecycle, pkg, "preuninstall", folder, false, true]
        , [lifecycle, pkg, "uninstall", folder, false, true]
        , !silent && function(cb) {
            console.log("unbuild " + pkg._id)
            cb()
          }
        , [rmStuff, pkg, folder]
        , [lifecycle, pkg, "postuninstall", folder, false, true]
        , [rm, folder] ]
      , cb )
  })
}}
github npm / init-package-json / init-package-json.js View on Github external
pz.on('data', function (data) {
      Object.keys(data).forEach(function (k) {
        if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
      })

      // only do a few of these.
      // no need for mans or contributors if they're in the files
      var es = readJson.extraSet
      readJson.extraSet = es.filter(function (fn) {
        return fn.name !== 'authors' && fn.name !== 'mans'
      })
      readJson.extras(packageFile, pkg, function (er, pkg) {
        readJson.extraSet = es
        if (er) return cb(er, pkg)
        pkg = unParsePeople(pkg)
        // no need for the readme now.
        delete pkg.readme
        delete pkg.readmeFilename

        // really don't want to have this lying around in the file
        delete pkg._id

        // ditto
        delete pkg.gitHead
github npm / init-package-json / init-package-json.js View on Github external
readJson(packageFile, function (er, d) {
    readJson.extraSet = es

    if (er) pkg = {}
    else pkg = d

    ctx.filename = packageFile
    ctx.dirname = path.dirname(packageFile)
    ctx.basename = path.basename(ctx.dirname)
    if (!pkg.version || !semver.valid(pkg.version))
      delete pkg.version

    ctx.package = pkg
    ctx.config = config || {}

    // make sure that the input is valid.
    // if not, use the default
    var pz = new PZ(input, ctx)
github davidhealey / waistline / node_modules / npm / node_modules / init-package-json / init-package-json.js View on Github external
readJson(packageFile, function (er, d) {
    readJson.extraSet = es

    if (er) pkg = {}
    else pkg = d

    ctx.filename = packageFile
    ctx.dirname = path.dirname(packageFile)
    ctx.basename = path.basename(ctx.dirname)
    if (!pkg.version || !semver.valid(pkg.version))
      delete pkg.version

    ctx.package = pkg
    ctx.config = config || {}

    // make sure that the input is valid.
    // if not, use the default
    var pz = new PZ(input, ctx)
github npm / init-package-json / init-package-json.js View on Github external
pz.on('data', function (data) {
      Object.keys(data).forEach(function (k) {
        if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
      })

      // only do a few of these.
      // no need for mans or contributors if they're in the files
      var es = readJson.extraSet
      readJson.extraSet = es.filter(function (fn) {
        return fn.name !== 'authors' && fn.name !== 'mans'
      })
      readJson.extras(packageFile, pkg, function (er, pkg) {
        readJson.extraSet = es
        if (er) return cb(er, pkg)
        pkg = unParsePeople(pkg)
        // no need for the readme now.
        delete pkg.readme
        delete pkg.readmeFilename

        // really don't want to have this lying around in the file
        delete pkg._id

        // ditto
        delete pkg.gitHead
github davidhealey / waistline / node_modules / npm / node_modules / init-package-json / init-package-json.js View on Github external
pz.on('data', function (data) {
      Object.keys(data).forEach(function (k) {
        if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
      })

      // only do a few of these.
      // no need for mans or contributors if they're in the files
      var es = readJson.extraSet
      readJson.extraSet = es.filter(function (fn) {
        return fn.name !== 'authors' && fn.name !== 'mans'
      })
      readJson.extras(packageFile, pkg, function (er, pkg) {
        readJson.extraSet = es
        if (er) return cb(er, pkg)
        pkg = unParsePeople(pkg)
        // no need for the readme now.
        delete pkg.readme
        delete pkg.readmeFilename

        // really don't want to have this lying around in the file
        delete pkg._id

        // ditto
        delete pkg.gitHead
github racker / node-rproxy / node_modules / cluster2 / node_modules / npm / lib / unbuild.js View on Github external
readJson(path.resolve(folder, "package.json"), function (er, pkg) {
    // if no json, then just trash it, but no scripts or whatever.
    if (er) return rm(folder, cb)
    readJson.cache.del(folder)
    chain
      ( [ [lifecycle, pkg, "preuninstall", folder, false, true]
        , [lifecycle, pkg, "uninstall", folder, false, true]
        , [rmStuff, pkg, folder]
        , [lifecycle, pkg, "postuninstall", folder, false, true]
        , [rm, folder] ]
      , cb )
  })
}
github davidhealey / waistline / node_modules / npm / node_modules / init-package-json / init-package-json.js View on Github external
pz.on('data', function (data) {
      Object.keys(data).forEach(function (k) {
        if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
      })

      // only do a few of these.
      // no need for mans or contributors if they're in the files
      var es = readJson.extraSet
      readJson.extraSet = es.filter(function (fn) {
        return fn.name !== 'authors' && fn.name !== 'mans'
      })
      readJson.extras(packageFile, pkg, function (er, pkg) {
        readJson.extraSet = es
        if (er) return cb(er, pkg)
        pkg = unParsePeople(pkg)
        // no need for the readme now.
        delete pkg.readme
        delete pkg.readmeFilename

        // really don't want to have this lying around in the file
        delete pkg._id

        // ditto
        delete pkg.gitHead

        // if the repo is empty, remove it.
        if (!pkg.repository)
          delete pkg.repository
github npm / init-package-json / init-package-json.js View on Github external
pz.on('data', function (data) {
      Object.keys(data).forEach(function (k) {
        if (data[k] !== undefined && data[k] !== null) pkg[k] = data[k]
      })

      // only do a few of these.
      // no need for mans or contributors if they're in the files
      var es = readJson.extraSet
      readJson.extraSet = es.filter(function (fn) {
        return fn.name !== 'authors' && fn.name !== 'mans'
      })
      readJson.extras(packageFile, pkg, function (er, pkg) {
        readJson.extraSet = es
        if (er) return cb(er, pkg)
        pkg = unParsePeople(pkg)
        // no need for the readme now.
        delete pkg.readme
        delete pkg.readmeFilename

        // really don't want to have this lying around in the file
        delete pkg._id

        // ditto
        delete pkg.gitHead

        // if the repo is empty, remove it.
        if (!pkg.repository)
          delete pkg.repository
github TypeStrong / atom-typescript / node_modules / atom-package-dependencies / node_modules / witwip / witwip.js View on Github external
var path = require('path'),
    fs = require('fs'),
    exists = fs.exists || path.exists,
    existsSync = fs.existsSync || path.existsSync,
    debug = require('debug')('witwip'),
    readJSON = require('read-package-json'),
    modulePathCache = {};

readJSON.log = {
  info: function() {},
  verbose: function() {},
  warn: function() {}
};

module.exports = witwip;

function witwip(base, modulePath, callback) {
  // If only a callback is passed, then find the package.json of the caller.
  if (typeof base === 'function') {
    callback = base;
    modulePath = null;
    base = module.parent;
  }

  // Allow base to be a module object (such as `module.parent`).

read-package-json

The thing npm uses to read package.json files with semantics and defaults and validation

ISC
Latest version published 7 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages