Add utility.isDir()
This commit is contained in:
parent
bb1cb465ea
commit
e2d44bd92c
23
utility.js
23
utility.js
@ -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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user