🌳
pt0/deployF/staticSiteF/textFileF.mts
1import path from 'path'
2import { existsSync } from 'fs'
3import { execSync } from 'child_process'
7const textFileExts = new Set(ptTextFileExtA)
8export const isTextFile = (filePath: string) => {
9 const ext = filePath.split('.').pop()?.toLowerCase()
10 const basename = path.basename(filePath)
11 return textFileExts.has(ext!) || basename.startsWith('.') || !filePath.includes('.')
14export const getTrackedFiles = async (trackedPaths: string[]) => {
15 const files: string[] = []
16 for (const tp of trackedPaths) {
17 if (tp.endsWith('/')) {
18 const abs = path.join(ptDir, tp)
19 if (!existsSync(abs)) continue
20 let result = ''
21 try {
22 result = execSync(`git ls-files --full-name "${tp}"`, {cwd: ptDir, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe']}).trim()
23 } catch { continue }
24 if (result) files.push(...result.split('\n').filter(Boolean))
25 } else {
26 if (!existsSync(path.join(ptDir, tp))) continue
27 files.push(tp)
28 }
29 }
30 return [...new Set(files)]