mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Avoid string template literal
This commit is contained in:
parent
a0c8751cb2
commit
f228ff9ac6
@ -82,9 +82,9 @@ export const buildRejectDomainSet = task(import.meta.main, import.meta.path)(asy
|
||||
const [type, value] = line.split(',');
|
||||
|
||||
if (type === 'DOMAIN-KEYWORD') {
|
||||
domainKeywordsSet.add(value.trim());
|
||||
domainKeywordsSet.add(value);
|
||||
} else if (type === 'DOMAIN-SUFFIX') {
|
||||
domainSets.add(`.${value.trim()}`); // Add to domainSets for later deduplication
|
||||
domainSets.add('.' + value); // Add to domainSets for later deduplication
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
Build/trim-source.ts
Normal file
47
Build/trim-source.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import path from 'path';
|
||||
import { fdir as Fdir } from 'fdir';
|
||||
import { readFileByLine } from './lib/fetch-text-by-line';
|
||||
|
||||
const sourceDir = path.resolve(import.meta.dir, '../Source');
|
||||
|
||||
(async () => {
|
||||
const promises: Array<Promise<unknown>> = [];
|
||||
|
||||
const paths = await new Fdir()
|
||||
.withFullPaths()
|
||||
// .exclude((dirName, dirPath) => {
|
||||
// if (dirName === 'domainset' || dirName === 'ip' || dirName === 'non_ip') {
|
||||
// return false;
|
||||
// }
|
||||
// console.error(picocolors.red(`[build-comman] Unknown dir: ${dirPath}`));
|
||||
// return true;
|
||||
// })
|
||||
.filter((filepath, isDirectory) => {
|
||||
if (isDirectory) return true;
|
||||
|
||||
const extname = path.extname(filepath);
|
||||
if (extname === '.js' || extname === '.ts') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
})
|
||||
.crawl(sourceDir)
|
||||
.withPromise();
|
||||
|
||||
for (let i = 0, len = paths.length; i < len; i++) {
|
||||
const fullPath = paths[i];
|
||||
promises.push(trimFileLines(fullPath));
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
})();
|
||||
|
||||
async function trimFileLines(file: string) {
|
||||
let result = '';
|
||||
for await (const line of readFileByLine(file)) {
|
||||
result += line.trim() + '\n';
|
||||
}
|
||||
|
||||
return Bun.write(file, result);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user