1 | 'use strict';
|
2 |
|
3 | var extend = require('xtend');
|
4 |
|
5 | function readPackageJson(filename) {
|
6 | var pkg = void 0;
|
7 | var error = void 0;
|
8 | try {
|
9 | pkg = require(filename);
|
10 | } catch (e) {
|
11 | if (e.code === 'MODULE_NOT_FOUND') {
|
12 | error = new Error('A package.json was not found at ' + filename);
|
13 | } else {
|
14 | error = new Error('A package.json was found at ' + filename + ', but it is not valid.');
|
15 | }
|
16 | }
|
17 | return extend({ devDependencies: {}, dependencies: {}, error: error }, pkg);
|
18 | }
|
19 |
|
20 | module.exports = readPackageJson; |
\ | No newline at end of file |