Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Create an explicit error when directories are matched without a packa…
Browse files Browse the repository at this point in the history
…ge.json file

 🐿 v2.10.0
  • Loading branch information
i-like-robots committed Feb 14, 2019
1 parent 19535f9 commit 9c8168f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/load-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ const fs = require('fs');
const path = require('path');

module.exports = (packagePath) => {
const manifestPath = path.resolve(packagePath, 'package.json');
const stats = fs.statSync(packagePath);

if (fs.existsSync(manifestPath)) {
return require(manifestPath);
if (stats.isDirectory()) {
const manifestPath = path.resolve(packagePath, 'package.json');

if (fs.existsSync(manifestPath)) {
return require(manifestPath);
} else {
throw Error(`Folder found without package.json file: ${packagePath}`)
}
}
};

0 comments on commit 9c8168f

Please sign in to comment.