mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Chore: Housekeeping & Make ESLint Happy
This commit is contained in:
@@ -34,11 +34,8 @@ export const buildCommon = task(require.main === module, __filename)(async (span
|
||||
if (isDirectory) return true;
|
||||
|
||||
const extname = path.extname(filepath);
|
||||
if (extname === '.js' || extname === '.ts') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(extname === '.js' || extname === '.ts');
|
||||
})
|
||||
.crawl(SOURCE_DIR)
|
||||
.withPromise();
|
||||
@@ -67,49 +64,46 @@ export const buildCommon = task(require.main === module, __filename)(async (span
|
||||
|
||||
const $skip = Symbol('skip');
|
||||
|
||||
const processFile = (span: Span, sourcePath: string) => {
|
||||
// console.log('Processing', sourcePath);
|
||||
return span.traceChildAsync(`process file: ${sourcePath}`, async () => {
|
||||
const lines: string[] = [];
|
||||
const processFile = (span: Span, sourcePath: string) => span.traceChildAsync(`process file: ${sourcePath}`, async () => {
|
||||
const lines: string[] = [];
|
||||
|
||||
let title = '';
|
||||
const descriptions: string[] = [];
|
||||
let sgmodulePathname: string | null = null;
|
||||
let title = '';
|
||||
const descriptions: string[] = [];
|
||||
let sgmodulePathname: string | null = null;
|
||||
|
||||
try {
|
||||
for await (const line of readFileByLine(sourcePath)) {
|
||||
if (line.startsWith(MAGIC_COMMAND_SKIP)) {
|
||||
return $skip;
|
||||
}
|
||||
|
||||
if (line.startsWith(MAGIC_COMMAND_TITLE)) {
|
||||
title = line.slice(MAGIC_COMMAND_TITLE.length).trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(MAGIC_COMMAND_DESCRIPTION)) {
|
||||
descriptions.push(line.slice(MAGIC_COMMAND_DESCRIPTION.length).trim());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES)) {
|
||||
sgmodulePathname = line.slice(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES.length).trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
const l = processLine(line);
|
||||
if (l) {
|
||||
lines.push(l);
|
||||
}
|
||||
try {
|
||||
for await (const line of readFileByLine(sourcePath)) {
|
||||
if (line.startsWith(MAGIC_COMMAND_SKIP)) {
|
||||
return $skip;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error processing', sourcePath);
|
||||
console.trace(e);
|
||||
}
|
||||
|
||||
return [title, descriptions, lines, sgmodulePathname] as const;
|
||||
});
|
||||
};
|
||||
if (line.startsWith(MAGIC_COMMAND_TITLE)) {
|
||||
title = line.slice(MAGIC_COMMAND_TITLE.length).trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(MAGIC_COMMAND_DESCRIPTION)) {
|
||||
descriptions.push(line.slice(MAGIC_COMMAND_DESCRIPTION.length).trim());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES)) {
|
||||
sgmodulePathname = line.slice(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES.length).trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
const l = processLine(line);
|
||||
if (l) {
|
||||
lines.push(l);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error processing', sourcePath);
|
||||
console.trace(e);
|
||||
}
|
||||
|
||||
return [title, descriptions, lines, sgmodulePathname] as const;
|
||||
});
|
||||
|
||||
function transformDomainset(parentSpan: Span, sourcePath: string, relativePath: string) {
|
||||
return parentSpan
|
||||
|
||||
Reference in New Issue
Block a user