summaryrefslogtreecommitdiff
path: root/fs/utils.ts
diff options
context:
space:
mode:
authorAxetroy <axetroy.dev@gmail.com>2019-04-24 05:42:02 +0800
committerRyan Dahl <ry@tinyclouds.org>2019-04-23 17:42:02 -0400
commit0fb83ba0d2e8facfa32e92a4d0700caad83701d9 (patch)
tree038510b68f62ec2f53bb7c52177c689ea63e043f /fs/utils.ts
parentbbdd51574c31c5c415176208187bc884ccaae3c6 (diff)
fs utils getFileInfoType() return undefined when not found (denoland/deno_std#341)
Original: https://github.com/denoland/deno_std/commit/0a6180016383b9d527bb96556ae0bcdabe5161eb
Diffstat (limited to 'fs/utils.ts')
-rw-r--r--fs/utils.ts24
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;
}