Add utility.isDir()
This commit is contained in:
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
|
* Load a file's content
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user