mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
WIP: fixing tests
This commit is contained in:
1 parent
8eaec839d3
commit
2bdb804f24
10 files changed
+49
-29
No files matched your search
@@ -0,0 +1,33 @@
|
||||
/* eslint-disable lines-between-class-members */
|
||||
import { basename } from './utils'
|
||||
|
||||
interface FileObject {
|
||||
path: string
|
||||
type: string
|
||||
discovered: boolean
|
||||
}
|
||||
|
||||
export default class File implements FileObject {
|
||||
path: string
|
||||
name: string
|
||||
type: string
|
||||
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 === 'folder'
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user