Skip to content

Commit 64b9b80

Browse files
fhammerschmidtcristianoc
authored andcommitted
Fix some style mistakes
1 parent 58fc4cd commit 64b9b80

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

server/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ let send: (msg: p.Message) => void = (_) => {};
6767

6868
let getBinaryDirPath = (projectRootPath: p.DocumentUri) =>
6969
extensionConfiguration.binaryPath === null
70-
? utils.findBinaryFromProjectRoot(projectRootPath)
70+
? utils.findBinaryDirPathFromProjectRoot(projectRootPath)
7171
: extensionConfiguration.binaryPath;
7272

7373
let findRescriptBinary = (projectRootPath: p.DocumentUri) =>

server/src/utils.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,23 @@ export let findProjectRootOfFile = (
3838
}
3939
};
4040

41-
export let findBinaryFromProjectRoot = (
42-
projectRootPath: p.DocumentUri // This must be a directory and not a file!
41+
export let findBinaryDirPathFromProjectRoot = (
42+
directory: p.DocumentUri // This must be a directory and not a file!
4343
): null | p.DocumentUri => {
44-
let dir = path.dirname(projectRootPath);
45-
let bscNativeReScriptPath = path.join(
46-
projectRootPath,
47-
c.nodeModulesBinDir,
48-
c.bscBinName
49-
);
50-
51-
if (fs.existsSync(bscNativeReScriptPath)) {
52-
return path.dirname(bscNativeReScriptPath);
53-
} else if (dir === projectRootPath) {
44+
let binaryDirPath = path.join(directory, c.nodeModulesBinDir);
45+
let binaryPath = path.join(binaryDirPath, c.rescriptBinName);
46+
47+
if (fs.existsSync(binaryPath)) {
48+
return binaryDirPath;
49+
}
50+
51+
let parentDir = path.dirname(directory);
52+
if (parentDir === directory) {
5453
// reached the top
5554
return null;
56-
} else {
57-
return findBinaryFromProjectRoot(dir);
5855
}
56+
57+
return findBinaryDirPathFromProjectRoot(parentDir);
5958
};
6059

6160
export let findBinary = (

0 commit comments

Comments
 (0)