Skip to content

Use fs api to check if string is a directory. #1080

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

Merged
merged 3 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

## master

#### :bug: Bug fix

- Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080

## 1.62.0

#### :nail_care: Polish
Expand Down
3 changes: 2 additions & 1 deletion server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export let findProjectRootOfFile = (
if (foundRootFromProjectFiles != null) {
return foundRootFromProjectFiles;
} else {
const isDir = path.extname(source) === "";
const dirStat = fs.statSync(source);
const isDir = dirStat.isDirectory();
Copy link
Collaborator

Choose a reason for hiding this comment

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

IIRC, this is in a hot path where we shouldn't use fs functions (which is why this fn looks the way it looks now). So we need to figure out another way to do this, outside of the hot path. OTOH maybe it could be aggressively cached in some sane way (unlikely), or moved outside of the hot path entirely to some sort of setup function somewhere. Would need to be explored.

return findProjectRootOfFileInDir(
isDir && !allowDir ? path.join(source, "dummy.res") : source
);
Expand Down