Ensure packages loaded are directories
This commit is contained in:
parent
0b3741859f
commit
b5d96d215f
@ -39,12 +39,21 @@ function loadPackages() {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
packages.forEach((packageName) => {
|
||||
fs.stat(Helper.getPackageModulePath(packageName), function(err2, stat) {
|
||||
if (err2 || !stat.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const packageFile = getModuleInfo(packageName);
|
||||
|
||||
if (!packageFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
packageMap.set(packageName, packageFile);
|
||||
|
||||
if (packageFile.type === "theme") {
|
||||
themes.addTheme(packageName, packageFile);
|
||||
}
|
||||
@ -54,19 +63,16 @@ function loadPackages() {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getModuleInfo(packageName) {
|
||||
let module;
|
||||
try {
|
||||
module = require(Helper.getPackageModulePath(packageName));
|
||||
} catch (e) {
|
||||
log.warn(`Specified package ${colors.yellow(packageName)} is not installed in packages directory`);
|
||||
return;
|
||||
}
|
||||
const module = require(Helper.getPackageModulePath(packageName));
|
||||
|
||||
if (!module.thelounge) {
|
||||
log.warn(`Specified package ${colors.yellow(packageName)} doesn't have required information.`);
|
||||
return;
|
||||
}
|
||||
|
||||
return module.thelounge;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user