0.4.1 • Published 7 years ago

pkginfo v0.4.1

Weekly downloads
1,706,922
License
MIT
Repository
github
Last release
7 years ago

node-pkginfo

An easy way to expose properties on a module from a package.json

Installing pkginfo

  npm install pkginfo

Motivation

How often when writing node.js modules have you written the following line(s) of code?

  • Hard code your version string into your code
  exports.version = '0.1.0';
  • Programmatically expose the version from the package.json
  exports.version = require('/path/to/package.json').version;

In other words, how often have you wanted to expose basic information from your package.json onto your module programmatically? WELL NOW YOU CAN!

Usage

Using pkginfo is idiot-proof, just require and invoke it.

  var pkginfo = require('pkginfo')(module);

  console.dir(module.exports);

By invoking the pkginfo module all of the properties in your package.json file will be automatically exposed on the callee module (i.e. the parent module of pkginfo).

Here's a sample of the output:

  { name: 'simple-app',
    description: 'A test fixture for pkginfo',
    version: '0.1.0',
    author: 'Charlie Robbins <charlie.robbins@gmail.com>',
    keywords: [ 'test', 'fixture' ],
    main: './index.js',
    scripts: { test: 'vows test/*-test.js --spec' },
    engines: { node: '>= 0.4.0' } }

Expose specific properties

If you don't want to expose all properties on from your package.json on your module then simple pass those properties to the pkginfo function:

  var pkginfo = require('pkginfo')(module, 'version', 'author');

  console.dir(module.exports);
  { version: '0.1.0',
    author: 'Charlie Robbins <charlie.robbins@gmail.com>' }

If you're looking for further usage see the examples included in this repository.

Run Tests

Tests are written in vows and give complete coverage of all APIs.

  npm install
  npm test

Author: Charlie Robbins

License: MIT

explosionjswamp@md-app/loopback-component-oauth2-server@ff0000-tech/passport-google-token@sz-software/npkgmetalsmith-clean-htmlmetalsmith-linkmetalsmith-hrefpassport-pushbulletpassport-google-oauth-2passport-infusionsoftpassport-yahoo-contacts@anchor-indexer/graph-cli@infinitebrahmanuniverse/nolb-pkhook.io-fswatcherminium-nodepassport-yammer-updateunleash-server@everything-registry/sub-chunk-2443@wmp-sbd/aws-xray-sdk@wmp-sbd/aws-xray-sdk-coregiraffigpxsplitgitoriou.jsgitignrgit-foundgh-release-notesgraphite-feedergit-cruciblego-language-serverglob-tester-cligmondgoogle-sheets-i18n-generatorkroknet-passport-google-oauthktlint-to-mdkong-admin-node-clientkoa-passport-remember-meknack-winston-tcp-grayloglast-doc-generatorlasticlattesrobotjwt-encode-decode-appkafka-rest-clientkamstrup-ingestionkamulogomotiveloopback-component-oauth2-serverloopback-component-oauth2logger-wrapperlocomotivelog-file-readerlogulint-to-mdloopback-oauth2orizelotteryjunctionjunction-pubsubjunction-discokamboja-clikomodo-sdklesslinterlispjslynda-dllynn-clim2tlightsocks-nodejslims-oauth2magneticlzglucify-notifierlumberhansgrunt-html-buildergulp-email-adaptergulp-target-mimegulp-jsontoxmlgt-passport-httpgulp-etl-handlelinesgulp-etl-mysql-adaptergulp-etl-savestategulp-etl-sqlgulp-etl-tap-dbfgulp-etl-tap-flatgulp-etl-tap-mimegulp-etl-tap-spreadsheetgulp-etl-target-csvgulp-etl-target-flatgulp-etl-target-spreadsheetgulp-etl-target-textgulp-etl-transform-jsongulp-etl-tap-csvgulp-api-adapterharedishar-to-k6gulp-xmltojsongulp4-ps-tasksgranitegroove-passport-azure-oauthgrrhaibu-other
0.4.1

7 years ago

0.4.0

8 years ago

0.3.1

9 years ago

0.3.0

12 years ago

0.2.3

13 years ago

0.2.2

13 years ago

0.2.1

13 years ago

0.2.0

13 years ago

0.1.0

13 years ago