Add utility.isDir()

This commit is contained in:
Mohammad Fares 2018-10-14 21:35:21 +03:00
parent bb1cb465ea
commit e2d44bd92c

View File

@ -27,6 +27,29 @@ function isFile(filePath) {
}
/**
* Check if a path represents a valid path for a directory
*
* @param {String} dirPath an absolute or a relative path
* @return {Boolean}
*/
function isDir(dirPath) {
// Resolve the path into an absolute path
dirPath = di.path.resolve(dirPath);
try {
return di.fs.statSync(dirPath).isDirectory();
} catch (error) {
return false;
}
}
/**
* Load a file's content
*