mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Refactor: simplify more validation tools
This commit is contained in:
@@ -35,39 +35,19 @@ function onDomain(args: [string, boolean]) {
|
||||
.withPromise();
|
||||
|
||||
await Promise.all([
|
||||
...domainSets.map(runAgainstDomainset),
|
||||
...domainRules.map(runAgainstRuleset)
|
||||
]);
|
||||
...domainRules,
|
||||
...domainSets
|
||||
].map(filepath => runAgainstSourceFile(
|
||||
filepath,
|
||||
(domain: string, includeAllSubdomain: boolean) => queue.add(
|
||||
() => keyedAsyncMutexWithQueue(
|
||||
domain,
|
||||
() => isDomainAlive(domain, includeAllSubdomain)
|
||||
).then(onDomain)
|
||||
).then(() => console.log('[done]', filepath))
|
||||
)));
|
||||
|
||||
console.log();
|
||||
console.log();
|
||||
console.log(JSON.stringify(deadDomains));
|
||||
})();
|
||||
|
||||
export async function runAgainstRuleset(filepath: string) {
|
||||
const promises: Array<Promise<void>> = [];
|
||||
await runAgainstSourceFile(
|
||||
filepath,
|
||||
(domain: string, includeAllSubdomain: boolean) => queue.add(() => keyedAsyncMutexWithQueue(
|
||||
domain,
|
||||
() => isDomainAlive(domain, includeAllSubdomain)
|
||||
).then(onDomain))
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
console.log('[done]', filepath);
|
||||
}
|
||||
|
||||
export async function runAgainstDomainset(filepath: string) {
|
||||
const promises: Array<Promise<void>> = [];
|
||||
|
||||
await runAgainstSourceFile(
|
||||
filepath,
|
||||
(domain: string, includeAllSubdomain: boolean) => queue.add(() => keyedAsyncMutexWithQueue(
|
||||
domain,
|
||||
() => isDomainAlive(domain, includeAllSubdomain)
|
||||
).then(onDomain))
|
||||
);
|
||||
await Promise.all(promises);
|
||||
console.log('[done]', filepath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user