-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathutils.ts
41 lines (35 loc) · 1015 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as path from "path";
import * as fs from "fs";
import * as os from "os";
const platformDir =
process.arch === "arm64" ? process.platform + process.arch : process.platform;
const analysisDevPath = path.join(
path.dirname(__dirname),
"..",
"analysis",
"rescript-editor-analysis.exe"
);
export const analysisProdPath = path.join(
path.dirname(__dirname),
"..",
"server",
"analysis_binaries",
platformDir,
"rescript-editor-analysis.exe"
);
export const getAnalysisBinaryPath = (): string | null => {
if (fs.existsSync(analysisDevPath)) {
return analysisDevPath;
} else if (fs.existsSync(analysisProdPath)) {
return analysisProdPath;
} else {
return null;
}
};
let tempFilePrefix = "rescript_" + process.pid + "_";
let tempFileId = 0;
export const createFileInTempDir = (prefix = "", extension = "") => {
let tempFileName = prefix + "_" + tempFilePrefix + tempFileId + extension;
tempFileId = tempFileId + 1;
return path.join(os.tmpdir(), tempFileName);
};