-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.ts
More file actions
59 lines (56 loc) · 1.38 KB
/
index.ts
File metadata and controls
59 lines (56 loc) · 1.38 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import path from "path";
import { InstrumentHooks } from "./instruments/hooks";
import { LinuxPerf } from "./linux_perf/linux_perf";
interface NativeCore {
InstrumentHooks: InstrumentHooks;
LinuxPerf: typeof LinuxPerf;
}
interface NativeCoreWithBindingStatus extends NativeCore {
isBound: boolean;
}
let native_core: NativeCoreWithBindingStatus;
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const nativeCore = require("node-gyp-build")(
path.dirname(__dirname)
) as NativeCore;
native_core = {
...nativeCore,
isBound: true,
};
} catch (e) {
native_core = {
LinuxPerf: class LinuxPerf {
start() {
return false;
}
stop() {
return false;
}
},
InstrumentHooks: {
isInstrumented: () => {
return false;
},
startBenchmark: () => {
return 0;
},
stopBenchmark: () => {
return 0;
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setExecutedBenchmark: (_pid: number, _uri: string) => {
return 0;
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
setIntegration: (_name: string, _version: string) => {
return 0;
},
__codspeed_root_frame__: <T>(callback: () => T): T => {
return callback();
},
},
isBound: false,
};
}
export default native_core;