diff options
Diffstat (limited to 'fs/utils.ts')
| -rw-r--r-- | fs/utils.ts | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/utils.ts b/fs/utils.ts index 410e45909..06b4c295c 100644 --- a/fs/utils.ts +++ b/fs/utils.ts @@ -17,24 +17,24 @@ export function isSubdir( const srcArray = src.split(sep); const destArray = dest.split(sep); - return srcArray.reduce((acc, current, i) => { + return srcArray.reduce((acc: boolean, current, i) => { return acc && destArray[i] === current; }, true); } -export enum PathType { - file = "file", - dir = "dir", - symlink = "symlink" -} +export type PathType = "file" | "dir" | "symlink"; -/* Get a human readable file type string */ -export function getFileInfoType(fileInfo: Deno.FileInfo): PathType | null { +/** + * Get a human readable file type string. + * + * @param fileInfo A FileInfo describes a file and is returned by `stat`, `lstat` + */ +export function getFileInfoType(fileInfo: Deno.FileInfo): PathType { return fileInfo.isFile() - ? PathType.file + ? "file" : fileInfo.isDirectory() - ? PathType.dir + ? "dir" : fileInfo.isSymlink() - ? PathType.symlink - : null; + ? "symlink" + : undefined; } |
