1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 | const loadJSON = require('./load-json');
|
4 |
|
5 | module.exports = packagePath => {
|
6 | const stats = fs.statSync(packagePath);
|
7 |
|
8 | if (stats.isDirectory()) {
|
9 | const manifestPath = path.resolve(packagePath, 'package.json');
|
10 |
|
11 | if (fs.existsSync(manifestPath)) {
|
12 | return loadJSON(manifestPath);
|
13 | }
|
14 |
|
15 | throw new Error(
|
16 | `Folder found without package.json file: ${packagePath}`,
|
17 | );
|
18 | }
|
19 | };
|