mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-10-29 22:53:00 +00:00
Fix checking for non-empty folders in initcommand
This commit is contained in:
@@ -139,4 +139,21 @@ exports.isDirectory = function(dirPath) {
|
||||
return fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory();
|
||||
};
|
||||
|
||||
/*
|
||||
Check if a path identifies a directory that is empty
|
||||
*/
|
||||
exports.isDirectoryEmpty = function(dirPath) {
|
||||
if(!$tw.utils.isDirectory(dirPath)) {
|
||||
return false;
|
||||
}
|
||||
var files = fs.readdirSync(dirPath),
|
||||
empty = true;
|
||||
$tw.utils.each(files,function(file,index) {
|
||||
if(file.charAt(0) !== ".") {
|
||||
empty = false;
|
||||
}
|
||||
});
|
||||
return empty;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user