Skip to content

Commit

Permalink
Improve "No project root found" error message
Browse files Browse the repository at this point in the history
This error message is too vague and can be confusing for folks. We can
make it better by providing some more context.

More info: Galooshi/atom-import-js#13
  • Loading branch information
lencioni committed Apr 12, 2017
1 parent d0a1521 commit 935f36a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/__tests__/findProjectRoot-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ it('treats package folders as roots', () => {

it('throws if it can not find a folder', () => {
expect(() => findProjectRoot('/foo/bar/baz.js')).toThrowError(
'No project root found',
'No project root found, looking for a directory with either a package.json file or a node_modules directory.',
);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/findProjectRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const NODE_MODULES_PATTERN = /\/node_modules$/;

function findRecursive(directory) {
if (directory === '/') {
throw new Error('No project root found');
throw new Error('No project root found, looking for a directory with either a package.json file or a node_modules directory.');
}
const pathToPackageJson = path.join(directory, 'package.json');
const pathToNodeModulesFolder = path.join(directory, 'node_modules');
Expand Down

0 comments on commit 935f36a

Please sign in to comment.