1 | 'use strict';
|
2 | var resolvePkg = require('./resolve-pkg.js');
|
3 | var moduleBaseDir = require('./module-base-dir.js');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | module.exports = function pkg(name, dir) {
|
15 | if (name !== './') { name += '/'; }
|
16 |
|
17 | var modulePath = resolvePkg(name, dir);
|
18 | if (modulePath === null) { return null; }
|
19 |
|
20 | var baseDir = moduleBaseDir(modulePath, name);
|
21 | var thePackage = require(baseDir + '/package.json');
|
22 |
|
23 | thePackage.path = modulePath;
|
24 | thePackage.baseDir = baseDir;
|
25 |
|
26 | return thePackage;
|
27 | };
|