Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
Member 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
21 changes: 19 additions & 2 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export let findProjectRootOfFile = (
if (foundRootFromProjectFiles != null) {
return foundRootFromProjectFiles;
} else {
const dirStat = fs.statSync(source);
const isDir = dirStat.isDirectory();
const isDir = path.extname(source) === "";
return findProjectRootOfFileInDir(
isDir && !allowDir ? path.join(source, "dummy.res") : source
);
Expand Down Expand Up @@ -166,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