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 all 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
2 changes: 1 addition & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
filesDiagnostics: {},
namespaceName:
namespaceName.kind === "success" ? namespaceName.result : null,
rescriptVersion: utils.findReScriptVersion(projectRootPath),
rescriptVersion: utils.findReScriptVersionForProjectRoot(projectRootPath),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the root of the problem really.
Here my project is called ronnies.be, which is mistaken for a file.
At this point, we know it is a folder, so we can shortcut things I think.

bsbWatcherByEditor: null,
bscBinaryLocation: utils.findBscExeBinary(projectRootPath),
editorAnalysisLocation: utils.findEditorAnalysisBinary(projectRootPath),
Expand Down
18 changes: 18 additions & 0 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ export let findReScriptVersion = (
}
};

export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined {
let rescriptBinary = lookup.findFilePathFromProjectRoot(
projectRootPath,
path.join(c.nodeModulesBinDir, c.rescriptBinName)
);

if (rescriptBinary == null) {
return undefined;
}

try {
let version = childProcess.execSync(`${rescriptBinary} -v`);
return version.toString().trim();
} catch (e) {
return undefined;
}
}

// This is the path for the _builtin_ legacy analysis, that works for versions 11 and below.
let builtinBinaryPath: string | null = null;
if (fs.existsSync(c.builtinAnalysisDevPath)) {
Expand Down