# pkginfo

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

Latest version **0.4.1** (published 2017-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install pkginfo
pnpm add pkginfo
yarn add pkginfo
bun add pkginfo
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2017-08-23 |
| First published | 2011-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/pkginfo) |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 162 |
| Author | Charlie Robbins |
| Maintainers | indexzero |
| Keywords | info, tools, package.json |

## Links

- npm: https://www.npmjs.com/package/pkginfo
- Repository: https://github.com/indexzero/node-pkginfo
- Homepage: https://github.com/indexzero/node-pkginfo#readme
- Issues: https://github.com/indexzero/node-pkginfo/issues
- npm.io page: https://npm.io/package/pkginfo

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.4.1 (latest) — 2017-08-23
- 0.4.0 — 2016-03-02
- 0.3.1 — 2015-10-20
- 0.3.0 — 2013-01-18
- 0.2.3 — 2011-12-08
- 0.2.2 — 2011-07-13
- 0.2.1 — 2011-06-08

## README

# 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

``` js
  exports.version = '0.1.0';
```

* Programmatically expose the version from the package.json

``` js
  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.

``` js
  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:

``` js
  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][0] included in this repository.

## Run Tests
Tests are written in [vows][1] and give complete coverage of all APIs.

```
  npm install
  npm test
```

[0]: https://github.com/indexzero/node-pkginfo/tree/master/examples
[1]: http://vowsjs.org

#### Author: [Charlie Robbins](http://github.com/indexzero)
#### License: MIT

---
_Source: https://npm.io/package/pkginfo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
