fix: normalize remaining Windows gate paths
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/** Shared repository file discovery and line-oriented reference scanning. */
|
/** Shared repository file discovery and line-oriented reference scanning. */
|
||||||
|
|
||||||
import { globSync, readFileSync, realpathSync } from 'node:fs'
|
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. */
|
/** One authored path plus its canonical target for symlink deduplication. */
|
||||||
export interface RepoFile {
|
export interface RepoFile {
|
||||||
@@ -37,8 +37,9 @@ export function uniqueRepoFiles(
|
|||||||
const files: RepoFile[] = []
|
const files: RepoFile[] = []
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
for (const match of globSync(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
if (isExcluded(match)) continue
|
const repoPath = match.split(sep).join('/')
|
||||||
const abs = resolve(root, match)
|
if (isExcluded(repoPath)) continue
|
||||||
|
const abs = resolve(root, repoPath)
|
||||||
const real = realpathSync(abs)
|
const real = realpathSync(abs)
|
||||||
if (seen.has(real)) continue
|
if (seen.has(real)) continue
|
||||||
seen.add(real)
|
seen.add(real)
|
||||||
@@ -65,7 +66,7 @@ export function findReferenceViolations(
|
|||||||
normalize: (raw: string) => string,
|
normalize: (raw: string) => string,
|
||||||
isViolation: (ref: string) => boolean,
|
isViolation: (ref: string) => boolean,
|
||||||
): ReferenceViolation[] {
|
): ReferenceViolation[] {
|
||||||
const file = relative(root, absPath)
|
const file = relative(root, absPath).split(sep).join('/')
|
||||||
const out: ReferenceViolation[] = []
|
const out: ReferenceViolation[] = []
|
||||||
const lines = readFileSync(absPath, 'utf8').split('\n')
|
const lines = readFileSync(absPath, 'utf8').split('\n')
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import { createHash } from 'node:crypto'
|
import { createHash } from 'node:crypto'
|
||||||
import { existsSync, globSync, readFileSync, writeFileSync } from 'node:fs'
|
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 { fromMarkdown } from 'mdast-util-from-markdown'
|
||||||
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
||||||
import { gfm } from 'micromark-extension-gfm'
|
import { gfm } from 'micromark-extension-gfm'
|
||||||
@@ -176,7 +176,7 @@ function parse(content: string): Nodes {
|
|||||||
// Enumerate the scope once.
|
// Enumerate the scope once.
|
||||||
const files = new Set<string>()
|
const files = new Set<string>()
|
||||||
for (const pattern of SCOPE_PATTERNS) {
|
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 translations = [...files].filter(f => f.endsWith('.zh.md')).sort()
|
||||||
const metas = [...files].filter(f => f.endsWith('.i18n.yaml')).sort()
|
const metas = [...files].filter(f => f.endsWith('.i18n.yaml')).sort()
|
||||||
|
|||||||
Reference in New Issue
Block a user