-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbindings.js
133 lines (125 loc) · 3.41 KB
/
bindings.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* tslint:disable */
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync } = require('fs')
const { join } = require("path");
const { platform, arch } = process;
let nativeBinding = null;
let localFileExisted = false;
let loadError = null;
switch (platform) {
case "win32":
switch (arch) {
case "x64":
localFileExisted = existsSync(join(__dirname, "zola-bin.win32-x64-msvc.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.win32-x64-msvc.node");
} else {
nativeBinding = require("zola-bin-win32");
}
} catch (e) {
loadError = e;
}
break;
case "arm64":
localFileExisted = existsSync(join(__dirname, "zola-bin.win32-arm64-msvc.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.win32-arm64-msvc.node");
} else {
nativeBinding = require("zola-bin-win32-arm64-msvc");
}
} catch (e) {
loadError = e;
}
break;
default:
throw new Error(`Unsupported architecture on Windows: ${arch}`);
}
break;
case "darwin":
localFileExisted = existsSync(join(__dirname, "zola-bin.darwin-universal.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.darwin-universal.node");
} else {
nativeBinding = require("zola-bin-darwin-universal");
}
break;
} catch {}
switch (arch) {
case "x64":
localFileExisted = existsSync(join(__dirname, "zola-bin.darwin-x64.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.darwin-x64.node");
} else {
nativeBinding = require("zola-bin-darwin");
}
} catch (e) {
loadError = e;
}
break;
case "arm64":
localFileExisted = existsSync(join(__dirname, "zola-bin.darwin-arm64.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.darwin-arm64.node");
} else {
nativeBinding = require("zola-bin-darwin-arm64");
}
} catch (e) {
loadError = e;
}
break;
default:
throw new Error(`Unsupported architecture on macOS: ${arch}`);
}
break;
case "linux":
switch (arch) {
case "x64":
localFileExisted = existsSync(join(__dirname, "zola-bin.linux-x64-gnu.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.linux-x64-gnu.node");
} else {
nativeBinding = require("zola-bin-linux");
}
} catch (e) {
loadError = e;
}
break;
case "arm64":
localFileExisted = existsSync(join(__dirname, "zola-bin.linux-arm64-gnu.node"));
try {
if (localFileExisted) {
nativeBinding = require("./zola-bin.linux-arm64-gnu.node");
} else {
nativeBinding = require("zola-bin-linux-arm64-gnu");
}
} catch (e) {
loadError = e;
}
break;
default:
throw new Error(`Unsupported architecture on Linux: ${arch}`);
}
break;
default:
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
}
if (!nativeBinding) {
if (loadError) {
throw loadError;
}
throw new Error(`Failed to load native binding`);
}
const { rawZolaBuild, rawZolaInit, rawZolaCheck, rawZolaServe, zolaCommandParse } = nativeBinding;
module.exports.rawZolaBuild = rawZolaBuild;
module.exports.rawZolaInit = rawZolaInit;
module.exports.rawZolaCheck = rawZolaCheck;
module.exports.rawZolaServe = rawZolaServe;
module.exports.zolaCommandParse = zolaCommandParse;