Skip to content

Commit c6c30b5

Browse files
fhammerschmidtcristianoc
authored andcommitted
Move findBinaryDirPathFromProjectRoot from utils to server
1 parent 64b9b80 commit c6c30b5

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

server/src/server.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,28 @@ let codeActionsFromDiagnostics: codeActions.filesCodeActions = {};
6565
// will be properly defined later depending on the mode (stdio/node-rpc)
6666
let send: (msg: p.Message) => void = (_) => {};
6767

68+
let findBinaryDirPathFromProjectRoot = (
69+
directory: p.DocumentUri // This must be a directory and not a file!
70+
): null | p.DocumentUri => {
71+
let binaryDirPath = path.join(directory, c.nodeModulesBinDir);
72+
let binaryPath = path.join(binaryDirPath, c.rescriptBinName);
73+
74+
if (fs.existsSync(binaryPath)) {
75+
return binaryDirPath;
76+
}
77+
78+
let parentDir = path.dirname(directory);
79+
if (parentDir === directory) {
80+
// reached the top
81+
return null;
82+
}
83+
84+
return findBinaryDirPathFromProjectRoot(parentDir);
85+
};
86+
6887
let getBinaryDirPath = (projectRootPath: p.DocumentUri) =>
6988
extensionConfiguration.binaryPath === null
70-
? utils.findBinaryDirPathFromProjectRoot(projectRootPath)
89+
? findBinaryDirPathFromProjectRoot(projectRootPath)
7190
: extensionConfiguration.binaryPath;
7291

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

server/src/utils.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,6 @@ export let findProjectRootOfFile = (
3838
}
3939
};
4040

41-
export let findBinaryDirPathFromProjectRoot = (
42-
directory: p.DocumentUri // This must be a directory and not a file!
43-
): null | p.DocumentUri => {
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) {
53-
// reached the top
54-
return null;
55-
}
56-
57-
return findBinaryDirPathFromProjectRoot(parentDir);
58-
};
59-
6041
export let findBinary = (
6142
binaryDirPath: p.DocumentUri | null,
6243
binaryName: string

0 commit comments

Comments
 (0)