Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useful changes from my setup which I think may be beneficial to others #506

Closed
wants to merge 18 commits into from
8 changes: 7 additions & 1 deletion lib/findProjectRoot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import FileUtils from './FileUtils';

const isWinDriveRoot = /^[A-Z]:\\$/;

Expand All @@ -11,7 +12,12 @@ function findRecursive(directory) {
const pathToPackageJson = path.join(directory, 'package.json');

if (fs.existsSync(pathToPackageJson)) {
return directory;
const packageDescription = FileUtils.readJsonFile(pathToPackageJson);
const { isRoot = true } = packageDescription['import-js'] || {};

if (isRoot) {
return directory;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks useful, and I'm assuming it's a continuation of #462? An update to findProjectRoot-test.js as well as an entry in the README and I think this is good to go. 👍

}

return findRecursive(path.dirname(directory));
Expand Down