1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Nodejs 16 does not support fetch()

This commit is contained in:
Raymond Hill 2022-09-06 15:05:01 -04:00
parent 84ab5dbb66
commit e420b75b91
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -24,6 +24,7 @@
/******************************************************************************/
import fs from 'fs/promises';
import https from 'https';
import process from 'process';
import rulesetConfigs from './ruleset-config.js';
@ -110,9 +111,19 @@ async function main() {
const rulesetDirPromise = fs.mkdir(`${rulesetDir}`, { recursive: true });
const fetchList = url => {
return fetch(url)
.then(response => response.text())
.then(text => ({ name: url, text }));
return new Promise((resolve, reject) => {
https.get(url, response => {
const data = [];
response.on('data', chunk => {
data.push(chunk.toString());
});
response.on('end', ( ) => {
resolve({ name: url, text: data.join('') });
});
}).on('error', error => {
reject(error);
});
});
};
const readList = path =>