File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
// clang-format off
2
+ const https = require ( "https" ) ;
2
3
const fs = require ( "fs" ) . promises ;
3
4
const assert = require ( "assert" ) ;
4
5
const pathUtil = require ( "path" ) ;
@@ -140,7 +141,7 @@ const modules = [
140
141
141
142
let jsCode = "" ;
142
143
for ( const m of modules ) {
143
- const content = await ( await fetch ( m ) ) . text ( ) ;
144
+ const content = await fetchContent ( m ) ;
144
145
jsCode += transpileTSEnums ( content ) ;
145
146
}
146
147
@@ -210,3 +211,24 @@ function showLog(...args) {
210
211
function showError ( ...args ) {
211
212
console . error ( `[${ getTime ( ) } ]` , ...args ) ;
212
213
}
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
+ }
You can’t perform that action at this time.
0 commit comments