Skip to content

Commit

Permalink
Remove try-catch in directoryContainsRootPackageJson (package.json pa…
Browse files Browse the repository at this point in the history
…rse error)
  • Loading branch information
isachivka committed Oct 14, 2020
1 parent 70b9da0 commit ad95742
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ const isSubPath = (parent, path) => {
};

const directoryContainsRootPackageJson = (path) => {
try {
const pathToCheck = resolve(path, 'package.json');
if (!fs.existsSync(pathToCheck)) return false;
const pkg = require(pathToCheck);
if (pkg && {}.hasOwnProperty.call(pkg, 'workspaces')) {
return true;
}
} catch (e) {
return false;
const pathToCheck = resolve(path, 'package.json');
if (!fs.existsSync(pathToCheck)) return false;
const pkg = require(pathToCheck);
if (pkg && {}.hasOwnProperty.call(pkg, 'workspaces')) {
return true;
}
};

Expand Down

0 comments on commit ad95742

Please sign in to comment.