feat: add file matcher

This commit is contained in:
wancat committed 2024-03-08 00:13:38 +08:00
1 parent b5e20766a3
commit d612b2d6af
4 files changed
+123

No files matched your search

@@ -0,0 +1,15 @@
import { FileInput, IFileExistenceChecker } from '../types'
interface FileExistenceInput extends FileInput {
exists: boolean
}
export async function checkFiles(
checker: IFileExistenceChecker,
files: FileExistenceInput[]
) {
const existences = await Promise.all(
files.map((file) => checker.exists(file))
)
return existences.every((exists, index) => exists === files[index].exists)
}
+14
View File
@@ -13,3 +13,17 @@ export interface ICondition {
or?: ICondition[]
not?: ICondition
}
export enum FileType {
FILE = 'file',
FOLDER = 'folder',
}
export interface FileInput {
path: string
type: FileType
}
export interface IFileExistenceChecker {
exists(file: FileInput): Promise<boolean>
}