diff --git a/Build/build-common.ts b/Build/build-common.ts index 950fa979..fe0e5bc2 100644 --- a/Build/build-common.ts +++ b/Build/build-common.ts @@ -1,7 +1,6 @@ // @ts-check import * as path from 'path'; -import { PathScurry } from 'path-scurry'; import { readFileByLine } from './lib/fetch-text-by-line'; import { processLine } from './lib/process-line'; import { createRuleset } from './lib/create-file'; @@ -10,6 +9,7 @@ import type { Span } from './trace'; import { task } from './trace'; import { SHARED_DESCRIPTION } from './lib/constants'; import picocolors from 'picocolors'; +import { fdir as Fdir } from 'fdir'; const MAGIC_COMMAND_SKIP = '# $ custom_build_script'; const MAGIC_COMMAND_TITLE = '# $ meta_title '; @@ -22,27 +22,29 @@ const outputClashDir = path.resolve(import.meta.dir, '../Clash'); export const buildCommon = task(import.meta.path, async (span) => { const promises: Array> = []; - const pw = new PathScurry(sourceDir); - for await (const entry of pw) { - if (!entry.isFile()) { - continue; - } + const paths = await new Fdir() + .withRelativePaths() + .crawl(sourceDir) + .withPromise(); - const extname = path.extname(entry.name); + for (let i = 0, len = paths.length; i < len; i++) { + const relativePath = paths[i]; + + const extname = path.extname(relativePath); if (extname === '.js' || extname === '.ts') { continue; } + const fullPath = sourceDir + path.sep + relativePath; - const relativePath = entry.relative(); if (relativePath.startsWith('domainset/')) { - promises.push(transformDomainset(span, entry.fullpath(), relativePath)); + promises.push(transformDomainset(span, fullPath, relativePath)); continue; } if ( relativePath.startsWith('ip/') || relativePath.startsWith('non_ip/') ) { - promises.push(transformRuleset(span, entry.fullpath(), relativePath)); + promises.push(transformRuleset(span, fullPath, relativePath)); continue; } diff --git a/bun.lockb b/bun.lockb index 8ec2fe89..5c9ee1c4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index f32390ff..cafa9e95 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "ci-info": "^4.0.0", "csv-parse": "^5.5.6", "fast-cidr-tools": "^0.2.5", + "fdir": "^6.1.1", "mnemonist": "^0.39.8", "path-scurry": "^1.11.1", "picocolors": "^1.0.1",