Skip to content

Commit cd42e8b

Browse files
authored
Use fs api to check if string is a directory. (#1080)
* Use fs api to check if string is a directory. * Changelog entry * Use findReScriptVersionForProjectRoot
1 parent 79992f1 commit cd42e8b

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
## master
1414

15+
#### :bug: Bug fix
16+
17+
- Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080
18+
1519
## 1.62.0
1620

1721
#### :nail_care: Polish

server/src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
268268
filesDiagnostics: {},
269269
namespaceName:
270270
namespaceName.kind === "success" ? namespaceName.result : null,
271-
rescriptVersion: utils.findReScriptVersion(projectRootPath),
271+
rescriptVersion: utils.findReScriptVersionForProjectRoot(projectRootPath),
272272
bsbWatcherByEditor: null,
273273
bscBinaryLocation: utils.findBscExeBinary(projectRootPath),
274274
editorAnalysisLocation: utils.findEditorAnalysisBinary(projectRootPath),

server/src/utils.ts

+18
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ export let findReScriptVersion = (
165165
}
166166
};
167167

168+
export function findReScriptVersionForProjectRoot(projectRootPath:string) : string | undefined {
169+
let rescriptBinary = lookup.findFilePathFromProjectRoot(
170+
projectRootPath,
171+
path.join(c.nodeModulesBinDir, c.rescriptBinName)
172+
);
173+
174+
if (rescriptBinary == null) {
175+
return undefined;
176+
}
177+
178+
try {
179+
let version = childProcess.execSync(`${rescriptBinary} -v`);
180+
return version.toString().trim();
181+
} catch (e) {
182+
return undefined;
183+
}
184+
}
185+
168186
// This is the path for the _builtin_ legacy analysis, that works for versions 11 and below.
169187
let builtinBinaryPath: string | null = null;
170188
if (fs.existsSync(c.builtinAnalysisDevPath)) {

0 commit comments

Comments
 (0)