Skip to content

Commit

Permalink
fix #319
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Aug 9, 2024
1 parent 4168d6e commit 88b992a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tools/enums-transpiler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// clang-format off
const https = require("https");
const fs = require("fs").promises;
const assert = require("assert");
const pathUtil = require("path");
Expand Down Expand Up @@ -140,7 +141,7 @@ const modules = [

let jsCode = "";
for (const m of modules) {
const content = await (await fetch(m)).text();
const content = await fetchContent(m);
jsCode += transpileTSEnums(content);
}

Expand Down Expand Up @@ -210,3 +211,24 @@ function showLog(...args) {
function showError(...args) {
console.error(`[${getTime()}]`, ...args);
}

function fetchContent(url) {
return new Promise((resolve, reject) => {
https.get(url, (response) => {
let data = '';

// A chunk of data has been received.
response.on('data', (chunk) => {
data += chunk;
});

// The whole response has been received.
response.on('end', () => {
resolve(data);
});

}).on('error', (error) => {
reject(error);
});
});
}

0 comments on commit 88b992a

Please sign in to comment.