Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / pkginfo / README.md
1 # node-pkginfo
2
3 An easy way to expose properties on a module from a package.json
4
5 ## Installation
6
7 ### Installing npm (node package manager)
8 ```
9   curl http://npmjs.org/install.sh | sh
10 ```
11
12 ### Installing pkginfo
13 ```
14   [sudo] npm install pkginfo
15 ```
16
17 ## Motivation
18 How often when writing node.js modules have you written the following line(s) of code? 
19
20 * Hard code your version string into your code
21
22 ``` js
23   exports.version = '0.1.0';
24 ```
25
26 * Programmatically expose the version from the package.json
27
28 ``` js
29   exports.version = require('/path/to/package.json').version;
30 ```
31
32 In other words, how often have you wanted to expose basic information from your package.json onto your module programmatically? **WELL NOW YOU CAN!**
33
34 ## Usage
35
36 Using `pkginfo` is idiot-proof, just require and invoke it. 
37
38 ``` js
39   var pkginfo = require('pkginfo')(module);
40   
41   console.dir(module.exports);
42 ```
43
44 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`). 
45
46 Here's a sample of the output:
47
48 ```
49   { name: 'simple-app',
50     description: 'A test fixture for pkginfo',
51     version: '0.1.0',
52     author: 'Charlie Robbins <charlie.robbins@gmail.com>',
53     keywords: [ 'test', 'fixture' ],
54     main: './index.js',
55     scripts: { test: 'vows test/*-test.js --spec' },
56     engines: { node: '>= 0.4.0' } }
57 ```
58
59 ### Expose specific properties
60 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:
61
62 ``` js
63   var pkginfo = require('pkginfo')(module, 'version', 'author');
64   
65   console.dir(module.exports);
66 ```
67
68 ```
69   { version: '0.1.0',
70     author: 'Charlie Robbins <charlie.robbins@gmail.com>' }
71 ```
72
73 If you're looking for further usage see the [examples][0] included in this repository. 
74
75 ## Run Tests
76 Tests are written in [vows][1] and give complete coverage of all APIs.
77
78 ```
79   vows test/*-test.js --spec
80 ```
81
82 [0]: https://github.com/indexzero/node-pkginfo/tree/master/examples
83 [1]: http://vowsjs.org
84
85 #### Author: [Charlie Robbins](http://nodejitsu.com)
86 #### License: MIT