1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

makelibrary command should skip non-directories

Fixes #4583
This commit is contained in:
jeremy@jermolene.com 2020-04-20 11:47:54 +01:00
parent 15d7255728
commit 678e25f510
2 changed files with 18 additions and 2 deletions

View File

@ -33,7 +33,7 @@ Command.prototype.execute = function() {
tiddlers = {};
// Collect up the library plugins
var collectPlugins = function(folder) {
var pluginFolders = fs.readdirSync(folder);
var pluginFolders = $tw.utils.getSubdirectories(folder);
for(var p=0; p<pluginFolders.length; p++) {
if(!$tw.boot.excludeRegExp.test(pluginFolders[p])) {
pluginFields = $tw.loadPluginFolder(path.resolve(folder,"./" + pluginFolders[p]));
@ -44,7 +44,7 @@ Command.prototype.execute = function() {
}
},
collectPublisherPlugins = function(folder) {
var publisherFolders = fs.readdirSync(folder);
var publisherFolders = $tw.utils.getSubdirectories(folder);
for(var t=0; t<publisherFolders.length; t++) {
if(!$tw.boot.excludeRegExp.test(publisherFolders[t])) {
collectPlugins(path.resolve(folder,"./" + publisherFolders[t]));

View File

@ -15,6 +15,22 @@ File system utilities
var fs = require("fs"),
path = require("path");
/*
Return the subdirectories of a path
*/
exports.getSubdirectories = function(dirPath) {
if(!$tw.utils.isDirectory(dirPath)) {
return null;
}
var subdirs = [];
$tw.utils.each(fs.readdirSync(dirPath),function(itemPath) {
if($tw.utils.isDirectory(itemPath)) {
subdirs.push(itemPath);
}
});
return subdirs;
}
/*
Recursively (and synchronously) copy a directory and all its content
*/