NPM.parsePackageJson()

Parse metadata for the latest version of the NPM package given a package.json string.

This machine understands how to parse both a normal package.json string, as well as a rich package.json string downloaded from an NPM registry.

Usage

Hover over inputs/exits for more info.

var NPM = require('machinepack-npm');


// Parse metadata for the latest version of the NPM package given a package.json string.

NPM.parsePackageJson({

json: '{...packagejson contents...}',

}).execSync();

Inputs

json required

The package.json string for the NPM package.

'{...packagejson contents...}'

Exits

error

An unexpected error occurred.

invalid

NPM package.json string is in an invalid format.

success

OK.

{ name: 'browserify',
  description: 'asg',
  version: '0.1.1',
  keywords: [ 'machine' ],
  latestVersionPublishedAt: '2015-01-19T22:26:54.588Z',
  npmUrl: 'http://npmjs.org/package/machinepack-foo',
  sourceUrl: 'https://github.com/baz/machinepack-foo',
  author: 'Substack <substack@substack.com>',
  main: 'lib/index.js',
  dependencies: [ { name: 'lodash', semverRange: '^2.4.1' } ],
  license: 'MIT',
  contributors: [ { name: 'Substack', email: 'substack@substack.com' } ],
  rawJson: '{...package.json data as a JSON string...}' }