mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Support Clash Fake IP Filter Ruleset
This commit is contained in:
@@ -65,10 +65,7 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
||||
return result;
|
||||
};
|
||||
|
||||
constructor(
|
||||
protected readonly span: Span,
|
||||
protected readonly id: string
|
||||
) { }
|
||||
constructor(protected readonly span: Span, protected readonly id: string) { }
|
||||
|
||||
protected title: string | null = null;
|
||||
withTitle(title: string) {
|
||||
@@ -245,7 +242,6 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
||||
}
|
||||
|
||||
private $$preprocessed: TPreprocessed | null = null;
|
||||
|
||||
get $preprocessed() {
|
||||
if (this.$$preprocessed === null) {
|
||||
this.$$preprocessed = this.span.traceChildSync('RuleOutput#preprocess: ' + this.id, () => this.preprocess());
|
||||
@@ -253,6 +249,24 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
||||
return this.$$preprocessed;
|
||||
}
|
||||
|
||||
async writeClash(outputDir?: null | string) {
|
||||
await this.done();
|
||||
|
||||
invariant(this.title, 'Missing title');
|
||||
invariant(this.description, 'Missing description');
|
||||
|
||||
return compareAndWriteFile(
|
||||
this.span,
|
||||
withBannerArray(
|
||||
this.title,
|
||||
this.description,
|
||||
this.date,
|
||||
this.clash()
|
||||
),
|
||||
path.join(outputDir ?? OUTPUT_CLASH_DIR, this.type, this.id + '.txt')
|
||||
);
|
||||
}
|
||||
|
||||
async write(): Promise<void> {
|
||||
await this.done();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user