Skip to content

Commit 88b992a

Browse files
committedAug 9, 2024··
fix #319
1 parent 4168d6e commit 88b992a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed
 

‎tools/enums-transpiler.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// clang-format off
2+
const https = require("https");
23
const fs = require("fs").promises;
34
const assert = require("assert");
45
const pathUtil = require("path");
@@ -140,7 +141,7 @@ const modules = [
140141

141142
let jsCode = "";
142143
for (const m of modules) {
143-
const content = await (await fetch(m)).text();
144+
const content = await fetchContent(m);
144145
jsCode += transpileTSEnums(content);
145146
}
146147

@@ -210,3 +211,24 @@ function showLog(...args) {
210211
function showError(...args) {
211212
console.error(`[${getTime()}]`, ...args);
212213
}
214+
215+
function fetchContent(url) {
216+
return new Promise((resolve, reject) => {
217+
https.get(url, (response) => {
218+
let data = '';
219+
220+
// A chunk of data has been received.
221+
response.on('data', (chunk) => {
222+
data += chunk;
223+
});
224+
225+
// The whole response has been received.
226+
response.on('end', () => {
227+
resolve(data);
228+
});
229+
230+
}).on('error', (error) => {
231+
reject(error);
232+
});
233+
});
234+
}

0 commit comments

Comments
 (0)
Please sign in to comment.