wip: replace packages with pure files

This commit is contained in:
Justin Lin committed 2025-04-24 23:20:40 +08:00
1 parent 2d95ca382f
commit 87b8ca5d04
112 files changed
+740 -522

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
export interface File {
path: string
type: string
}
const fileTypes = new Map([
['file', '-f'],
['directory', '-d'],
['link', '-L'],
['socket', '-S'],
])
function sanitizePath(path: string): string {
return path.replace(/[^a-zA-Z0-9._/-]/g, '')
}
export function buildFileCheckCmd(file: File): string[] {
const { path, type } = file
return ['test', fileTypes.get(type) || '-e', sanitizePath(path)]
}