mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Fix build
This commit is contained in:
@@ -5,6 +5,7 @@ const { compareAndWriteFile } = require('./lib/string-array-compare');
|
||||
const { withBannerArray } = require('./lib/with-banner');
|
||||
const { fetchRemoteTextAndCreateReadlineInterface, readFileByLine } = require('./lib/fetch-remote-text-by-line');
|
||||
const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
||||
const { processLine } = require('./lib/process-line');
|
||||
|
||||
(async () => {
|
||||
console.time('Total Time - build-anti-bogus-domain');
|
||||
@@ -34,7 +35,10 @@ const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
result.push(line);
|
||||
const l = processLine(line);
|
||||
if (l) {
|
||||
result.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +53,16 @@ const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
||||
' - https://github.com/felixonmars/dnsmasq-china-list'
|
||||
];
|
||||
|
||||
await compareAndWriteFile(
|
||||
withBannerArray(
|
||||
'Sukka\'s Ruleset - Anti Bogus Domain',
|
||||
description,
|
||||
new Date(),
|
||||
surgeRulesetToClashClassicalTextRuleset(result)
|
||||
),
|
||||
path.resolve(__dirname, '../Clash/ip/reject.txt')
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
compareAndWriteFile(
|
||||
withBannerArray(
|
||||
|
||||
@@ -10,7 +10,7 @@ const { readFileByLine } = require('./fetch-remote-text-by-line');
|
||||
async function compareAndWriteFile(linesA, filePath) {
|
||||
await fse.ensureFile(filePath);
|
||||
|
||||
let isEqual = false;
|
||||
let isEqual = true;
|
||||
let index = 0;
|
||||
|
||||
for await (const lineB of readFileByLine(filePath)) {
|
||||
@@ -20,15 +20,14 @@ async function compareAndWriteFile(linesA, filePath) {
|
||||
if (lineA[0] === '#' && lineB[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lineA !== lineB) {
|
||||
isEqual = false;
|
||||
break;
|
||||
} else {
|
||||
isEqual = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isEqual) {
|
||||
if (!isEqual || index !== linesA.length - 1) {
|
||||
await fsPromises.writeFile(
|
||||
filePath,
|
||||
linesA.join('\n'),
|
||||
|
||||
Reference in New Issue
Block a user