Skip to content

Commit 08fd2b7

Browse files
committed
Add utils.checkIfDirectoryExists()
1 parent d5908e8 commit 08fd2b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/utils.ts

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ export function checkIfFileExists(filePath: string): boolean {
109109
}
110110
}
111111

112+
export function checkIfDirectoryExists(directoryPath: string): boolean {
113+
try {
114+
// tslint:disable-next-line:no-bitwise
115+
fs.accessSync(directoryPath, fs.constants.R_OK | fs.constants.O_DIRECTORY);
116+
return true;
117+
} catch (e) {
118+
return false;
119+
}
120+
}
121+
112122
export function getTimestampString() {
113123
const time = new Date();
114124
return `[${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}]`;

0 commit comments

Comments
 (0)