mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Chore: drop @sukka/listdir
This commit is contained in:
parent
9a0113bf69
commit
d9331b8b50
@ -1,7 +1,7 @@
|
||||
import { readFileByLine } from './lib/fetch-text-by-line';
|
||||
import pathFn from 'path';
|
||||
import table from 'table';
|
||||
import listDir from '@sukka/listdir';
|
||||
import { fdir as Fdir } from 'fdir';
|
||||
import { green, yellow } from 'picocolors';
|
||||
import { processLineFromReadline } from './lib/process-line';
|
||||
import { getHostname } from 'tldts';
|
||||
@ -37,12 +37,16 @@ const PRESET_MITM_HOSTNAMES = [
|
||||
|
||||
(async () => {
|
||||
const folderListPath = pathFn.resolve(__dirname, '../List/');
|
||||
const rulesets = await listDir(folderListPath);
|
||||
|
||||
const rulesets = await new Fdir()
|
||||
.withFullPaths()
|
||||
.crawl(folderListPath)
|
||||
.withPromise();
|
||||
|
||||
const urlRegexPaths: Array<{ origin: string, processed: string }> = [];
|
||||
|
||||
await Promise.all(rulesets.map(async file => {
|
||||
const content = await processLineFromReadline(readFileByLine(pathFn.join(folderListPath, file)));
|
||||
const content = await processLineFromReadline(readFileByLine(file));
|
||||
urlRegexPaths.push(
|
||||
...content
|
||||
.filter(i => (
|
||||
|
||||
@ -2,9 +2,11 @@ import path from 'path';
|
||||
import { task } from './trace';
|
||||
import { treeDir } from './lib/tree-dir';
|
||||
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
|
||||
import listDir from '@sukka/listdir';
|
||||
import { fdir as Fdir } from 'fdir';
|
||||
import { sort } from './lib/timsort';
|
||||
|
||||
import Trie from 'mnemonist/trie';
|
||||
|
||||
const rootPath = path.resolve(import.meta.dir, '../');
|
||||
const publicPath = path.resolve(import.meta.dir, '../public');
|
||||
|
||||
@ -22,13 +24,15 @@ export const buildPublic = task(import.meta.main, import.meta.path)(async (span)
|
||||
await span
|
||||
.traceChild('copy public files')
|
||||
.traceAsyncFn(async () => {
|
||||
const filesToBeCopied = (await listDir(
|
||||
rootPath,
|
||||
{
|
||||
ignoreHidden: true,
|
||||
ignorePattern: /node_modules|Build|public/
|
||||
}
|
||||
)).filter(file => folderAndFilesToBeDeployed.some(folderOrFile => file.startsWith(folderOrFile)));
|
||||
const trie = Trie.from(await new Fdir()
|
||||
.withRelativePaths()
|
||||
.exclude((dirName) => {
|
||||
return dirName === 'node_modules' || dirName === 'Build' || dirName === 'public' || dirName[0] === '.';
|
||||
})
|
||||
.crawl(rootPath)
|
||||
.withPromise());
|
||||
|
||||
const filesToBeCopied = folderAndFilesToBeDeployed.flatMap(folderOrFile => trie.find(folderOrFile));
|
||||
|
||||
return Promise.all(filesToBeCopied.map(file => {
|
||||
const src = path.resolve(rootPath, file);
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
"dependencies": {
|
||||
"@cliqz/adblocker": "^1.27.5",
|
||||
"@gorhill/publicsuffixlist": "3.0.1",
|
||||
"@sukka/listdir": "^0.3.1",
|
||||
"async-retry": "^1.3.3",
|
||||
"async-sema": "^3.1.1",
|
||||
"ci-info": "^4.0.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user