Skip to content

Commit

Permalink
debug: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-startsev committed Aug 27, 2021
1 parent 15aec82 commit e07f484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/src/core/resolve.js
Expand Up @@ -340,8 +340,10 @@ describe('resolve', function () {
expect(fileExistsWithCaseSync(f, testSettings))
.to.be.true;
});
it('detecting case should include parent folder path', function () {
it.only('detecting case should include parent folder path', function () {
const f = path.join(process.cwd().toUpperCase(), './tests/files/jsx/MyUnCoolComponent.jsx');
console.log(process.cwd());
console.log(f);
expect(fileExistsWithCaseSync(f, testSettings, true))
.to.be.false;
});
Expand Down
11 changes: 9 additions & 2 deletions utils/resolve.js
Expand Up @@ -55,21 +55,28 @@ function tryRequire(target, sourceFile) {
exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings, strict) {
// don't care if the FS is case-sensitive
if (CASE_SENSITIVE_FS) return true;

console.log('case insensitive');
// null means it resolved to a builtin
if (filepath === null) return true;
if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) return true;
const parsedPath = path.parse(filepath);
console.log('parsedPath', parsedPath);
const dir = parsedPath.dir;

let result = fileExistsCache.get(filepath, cacheSettings);
if (result != null) return result;
if (result != null) {
console.log('result', result);
return result;
}

// base case
if (dir === '' || parsedPath.root === filepath) {
console.log('dir', dir);
console.log('parsedPath.root', parsedPath.root);
result = true;
} else {
const filenames = fs.readdirSync(dir);
console.log('filenames:', filenames);
if (filenames.indexOf(parsedPath.base) === -1) {
result = false;
} else {
Expand Down

0 comments on commit e07f484

Please sign in to comment.