UNPKG

436 BJavaScriptView Raw
1const fs = require('fs');
2const path = require('path');
3const loadJSON = require('./load-json');
4
5module.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};