mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 22:10:22 +00:00
Merge pull request #3406 from thelounge/xpaw/package-load-stack
Print error and stacktrace when package fails to load
This commit is contained in:
commit
bfa97390be
1 changed files with 11 additions and 12 deletions
|
@ -65,23 +65,22 @@ function loadPackages() {
|
|||
}
|
||||
|
||||
packages.forEach((packageName) => {
|
||||
const errorMsg = `Package ${colors.bold(packageName)} could not be loaded`;
|
||||
let packageInfo;
|
||||
let packageFile;
|
||||
|
||||
try {
|
||||
packageInfo = require(path.join(
|
||||
Helper.getPackageModulePath(packageName),
|
||||
"package.json"
|
||||
));
|
||||
packageFile = require(Helper.getPackageModulePath(packageName));
|
||||
} catch (e) {
|
||||
log.warn(errorMsg);
|
||||
return;
|
||||
}
|
||||
const packagePath = Helper.getPackageModulePath(packageName);
|
||||
|
||||
packageInfo = require(path.join(packagePath, "package.json"));
|
||||
|
||||
if (!packageInfo.thelounge) {
|
||||
log.warn(errorMsg);
|
||||
throw "'thelounge' is not present in package.json";
|
||||
}
|
||||
|
||||
packageFile = require(packagePath);
|
||||
} catch (e) {
|
||||
log.error(`Package ${colors.bold(packageName)} could not be loaded: ${colors.red(e)}`);
|
||||
log.debug(e.stack);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue