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

+32
View File
@@ -0,0 +1,32 @@
import { basename } from './utils.js'
export interface FileObject {
path: string
type: 'file' | 'directory'
discovered: boolean
}
export default class File implements FileObject {
path: string
name: string
type: 'file' | 'directory'
discovered: boolean
constructor(obj: FileObject) {
this.path = obj.path.trimEnd()
this.name = basename(obj.path)
this.type = obj.type
this.discovered = obj.discovered
}
isDirectory() {
return this.type === 'directory'
}
contains(file: FileObject) {
if (!this.isDirectory()) return false
if (this.path === file.path) return true
const parentPath = this.path.endsWith('/') ? this.path : `${this.path}/`
return file.path.startsWith(parentPath)
}
}