mirror of https://github.com/gorhill/uBlock.git
Nodejs 16 does not support fetch()
This commit is contained in:
parent
84ab5dbb66
commit
e420b75b91
|
@ -24,6 +24,7 @@
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
|
import https from 'https';
|
||||||
import process from 'process';
|
import process from 'process';
|
||||||
|
|
||||||
import rulesetConfigs from './ruleset-config.js';
|
import rulesetConfigs from './ruleset-config.js';
|
||||||
|
@ -110,9 +111,19 @@ async function main() {
|
||||||
const rulesetDirPromise = fs.mkdir(`${rulesetDir}`, { recursive: true });
|
const rulesetDirPromise = fs.mkdir(`${rulesetDir}`, { recursive: true });
|
||||||
|
|
||||||
const fetchList = url => {
|
const fetchList = url => {
|
||||||
return fetch(url)
|
return new Promise((resolve, reject) => {
|
||||||
.then(response => response.text())
|
https.get(url, response => {
|
||||||
.then(text => ({ name: url, text }));
|
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 =>
|
const readList = path =>
|
||||||
|
|
Loading…
Reference in New Issue