Skip to content

Commit e59b002

Browse files
committed
rename and cleanup
1 parent 4229712 commit e59b002

File tree

3 files changed

+11
-41
lines changed

3 files changed

+11
-41
lines changed

server/src/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export let analysisProdPath = path.join(
2828

2929
export let rescriptBinName = "rescript";
3030

31-
export let bsbBinName = "bsb";
32-
3331
export let bscBinName = "bsc";
3432

3533
export let nodeModulesBinDir = path.join("node_modules", ".bin");
@@ -39,7 +37,6 @@ export let rescriptNodePartialPath = path.join(
3937
nodeModulesBinDir,
4038
rescriptBinName
4139
);
42-
export let bsbNodePartialPath = path.join(nodeModulesBinDir, bsbBinName);
4340

4441
export let bsbLock = ".bsb.lock";
4542
export let bsconfigPartialPath = "bsconfig.json";

server/src/server.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ 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 findBuildBinary = (projectRootPath: p.DocumentUri) =>
68+
let findRescriptBinary = (projectRootPath: p.DocumentUri) =>
6969
extensionConfiguration.binaryPath === null
7070
? utils.findBuildBinaryFromProjectRoot(projectRootPath)
7171
: utils.findBuildBinaryFromConfig(extensionConfiguration.binaryPath);
@@ -250,7 +250,7 @@ let openedFile = (fileUri: string, fileContent: string) => {
250250
// TODO: sometime stale .bsb.lock dangling. bsb -w knows .bsb.lock is
251251
// stale. Use that logic
252252
// TODO: close watcher when lang-server shuts down
253-
if (findBuildBinary(projectRootPath) != null) {
253+
if (findRescriptBinary(projectRootPath) != null) {
254254
let payload: clientSentBuildAction = {
255255
title: c.startBuildAction,
256256
projectRootPath: projectRootPath,
@@ -1081,11 +1081,10 @@ function onMessage(msg: p.Message) {
10811081
// TODO: close watcher when lang-server shuts down. However, by Node's
10821082
// default, these subprocesses are automatically killed when this
10831083
// language-server process exits
1084-
let found = findBuildBinary(projectRootPath);
1085-
if (found != null) {
1084+
let rescriptBinaryPath = findRescriptBinary(projectRootPath);
1085+
if (rescriptBinaryPath != null) {
10861086
let bsbProcess = utils.runBuildWatcherUsingValidBuildPath(
1087-
found.buildPath,
1088-
found.isReScript,
1087+
rescriptBinaryPath,
10891088
projectRootPath
10901089
);
10911090
let root = projectsFiles.get(projectRootPath)!;

server/src/utils.ts

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,37 +67,20 @@ export let findBscBinaryFromConfig = (
6767
return null;
6868
};
6969

70-
// The function is to check that the build binary file exists
71-
// and also determine what exactly the user is using ReScript or BuckleScript.
72-
// TODO: this doesn't handle file:/// scheme
73-
let findBuildBinaryBase = ({
74-
rescriptPath,
75-
bsbPath,
76-
}: {
77-
rescriptPath: p.DocumentUri;
78-
bsbPath: p.DocumentUri;
79-
}): null | { buildPath: p.DocumentUri; isReScript: boolean } => {
70+
let findBuildBinaryBase = (rescriptPath: string): string | null => {
8071
if (fs.existsSync(rescriptPath)) {
81-
return { buildPath: rescriptPath, isReScript: true };
82-
} else if (fs.existsSync(bsbPath)) {
83-
return { buildPath: bsbPath, isReScript: false };
72+
return rescriptPath;
8473
}
8574
return null;
8675
};
8776

8877
export let findBuildBinaryFromConfig = (
8978
pathToBinaryDirFromConfig: p.DocumentUri
9079
) =>
91-
findBuildBinaryBase({
92-
rescriptPath: path.join(pathToBinaryDirFromConfig, c.rescriptBinName),
93-
bsbPath: path.join(pathToBinaryDirFromConfig, c.bsbBinName),
94-
});
80+
findBuildBinaryBase(path.join(pathToBinaryDirFromConfig, c.rescriptBinName));
9581

9682
export let findBuildBinaryFromProjectRoot = (projectRootPath: p.DocumentUri) =>
97-
findBuildBinaryBase({
98-
rescriptPath: path.join(projectRootPath, c.rescriptNodePartialPath),
99-
bsbPath: path.join(projectRootPath, c.bsbNodePartialPath),
100-
});
83+
findBuildBinaryBase(path.join(projectRootPath, c.rescriptNodePartialPath));
10184

10285
type execResult =
10386
| {
@@ -338,7 +321,6 @@ export let getCompiledFilePath = (
338321

339322
export let runBuildWatcherUsingValidBuildPath = (
340323
buildPath: p.DocumentUri,
341-
isRescript: boolean,
342324
projectRootPath: p.DocumentUri
343325
) => {
344326
let cwdEnv = {
@@ -357,17 +339,9 @@ export let runBuildWatcherUsingValidBuildPath = (
357339
(since the path might have spaces), which `execFile` would have done
358340
for you under the hood
359341
*/
360-
if (isRescript) {
361-
return childProcess.exec(`"${buildPath}".cmd build -w`, cwdEnv);
362-
} else {
363-
return childProcess.exec(`"${buildPath}".cmd -w`, cwdEnv);
364-
}
342+
return childProcess.exec(`"${buildPath}".cmd build -w`, cwdEnv);
365343
} else {
366-
if (isRescript) {
367-
return childProcess.execFile(buildPath, ["build", "-w"], cwdEnv);
368-
} else {
369-
return childProcess.execFile(buildPath, ["-w"], cwdEnv);
370-
}
344+
return childProcess.execFile(buildPath, ["build", "-w"], cwdEnv);
371345
}
372346
};
373347

0 commit comments

Comments
 (0)