UNPKG

490 BJavaScriptView Raw
1/**
2 * @module package
3 *
4 * @description
5 * Export the parsing of the `package.json` file.
6 *
7 * @example
8 * var pkg = require('package');
9 * console.log( pkg.version );
10 */
11var FS = require("fs");
12var Path = require("path");
13
14
15var packageFile = Path.join(__dirname, "../package.json");
16var cfg = {};
17if( FS.existsSync( packageFile ) ) {
18 try {
19 cfg = JSON.parse( FS.readFileSync( packageFile ) );
20 }
21 // Just ignore parsing errors.
22 catch(ex) {};
23}
24
25
26module.exports = cfg;