mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +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 { withBannerArray } = require('./lib/with-banner');
|
||||||
const { fetchRemoteTextAndCreateReadlineInterface, readFileByLine } = require('./lib/fetch-remote-text-by-line');
|
const { fetchRemoteTextAndCreateReadlineInterface, readFileByLine } = require('./lib/fetch-remote-text-by-line');
|
||||||
const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
||||||
|
const { processLine } = require('./lib/process-line');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.time('Total Time - build-anti-bogus-domain');
|
console.time('Total Time - build-anti-bogus-domain');
|
||||||
@@ -34,7 +35,10 @@ const { surgeRulesetToClashClassicalTextRuleset } = require('./lib/clash');
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} 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'
|
' - 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([
|
await Promise.all([
|
||||||
compareAndWriteFile(
|
compareAndWriteFile(
|
||||||
withBannerArray(
|
withBannerArray(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const { readFileByLine } = require('./fetch-remote-text-by-line');
|
|||||||
async function compareAndWriteFile(linesA, filePath) {
|
async function compareAndWriteFile(linesA, filePath) {
|
||||||
await fse.ensureFile(filePath);
|
await fse.ensureFile(filePath);
|
||||||
|
|
||||||
let isEqual = false;
|
let isEqual = true;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
for await (const lineB of readFileByLine(filePath)) {
|
for await (const lineB of readFileByLine(filePath)) {
|
||||||
@@ -20,15 +20,14 @@ async function compareAndWriteFile(linesA, filePath) {
|
|||||||
if (lineA[0] === '#' && lineB[0] === '#') {
|
if (lineA[0] === '#' && lineB[0] === '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineA !== lineB) {
|
if (lineA !== lineB) {
|
||||||
isEqual = false;
|
isEqual = false;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
isEqual = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEqual) {
|
if (!isEqual || index !== linesA.length - 1) {
|
||||||
await fsPromises.writeFile(
|
await fsPromises.writeFile(
|
||||||
filePath,
|
filePath,
|
||||||
linesA.join('\n'),
|
linesA.join('\n'),
|
||||||
|
|||||||
@@ -121,7 +121,8 @@
|
|||||||
"build:apple-cdn",
|
"build:apple-cdn",
|
||||||
"build:phishing-domainset",
|
"build:phishing-domainset",
|
||||||
"build:reject-domainset",
|
"build:reject-domainset",
|
||||||
"build:cdn-conf"
|
"build:cdn-conf",
|
||||||
|
"build:common"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
|
|||||||
Reference in New Issue
Block a user