fix: normalize remaining Windows gate paths

This commit is contained in:
imccyu
2026-07-15 19:59:00 +08:00
parent 47858df1ef
commit 32cfd6c513
2 changed files with 7 additions and 6 deletions
+5 -4
View File
@@ -1,7 +1,7 @@
/** Shared repository file discovery and line-oriented reference scanning. */
import { globSync, readFileSync, realpathSync } from 'node:fs'
import { relative, resolve } from 'node:path'
import { relative, resolve, sep } from 'node:path'
/** One authored path plus its canonical target for symlink deduplication. */
export interface RepoFile {
@@ -37,8 +37,9 @@ export function uniqueRepoFiles(
const files: RepoFile[] = []
for (const pattern of patterns) {
for (const match of globSync(pattern, { cwd: root })) {
if (isExcluded(match)) continue
const abs = resolve(root, match)
const repoPath = match.split(sep).join('/')
if (isExcluded(repoPath)) continue
const abs = resolve(root, repoPath)
const real = realpathSync(abs)
if (seen.has(real)) continue
seen.add(real)
@@ -65,7 +66,7 @@ export function findReferenceViolations(
normalize: (raw: string) => string,
isViolation: (ref: string) => boolean,
): ReferenceViolation[] {
const file = relative(root, absPath)
const file = relative(root, absPath).split(sep).join('/')
const out: ReferenceViolation[] = []
const lines = readFileSync(absPath, 'utf8').split('\n')
for (let i = 0; i < lines.length; i++) {
+2 -2
View File
@@ -9,7 +9,7 @@
import { createHash } from 'node:crypto'
import { existsSync, globSync, readFileSync, writeFileSync } from 'node:fs'
import { basename, join, resolve } from 'node:path'
import { basename, join, resolve, sep } from 'node:path'
import { fromMarkdown } from 'mdast-util-from-markdown'
import { gfmFromMarkdown } from 'mdast-util-gfm'
import { gfm } from 'micromark-extension-gfm'
@@ -176,7 +176,7 @@ function parse(content: string): Nodes {
// Enumerate the scope once.
const files = new Set<string>()
for (const pattern of SCOPE_PATTERNS) {
for (const match of globSync(pattern, { cwd: root })) files.add(match)
for (const match of globSync(pattern, { cwd: root })) files.add(match.split(sep).join('/'))
}
const translations = [...files].filter(f => f.endsWith('.zh.md')).sort()
const metas = [...files].filter(f => f.endsWith('.i18n.yaml')).sort()