mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-17 21:41:06 +00:00
Fix crashing for module plugins
This commit is contained in:
parent
483269db4c
commit
8d9eb32073
1 changed files with 4 additions and 2 deletions
|
|
@ -23,15 +23,17 @@ module.exports.server = function(serv, settings) {
|
|||
for (var p in settings.plugins) {
|
||||
if (settings.plugins[p].disabled) continue;
|
||||
try {
|
||||
serv.addPlugin(p, require(p), settings.plugins[p]);
|
||||
require.resolve(p); // Check if it exists, if not do catch, otherwise jump to bottom
|
||||
} catch (err) {
|
||||
try { // Throw error if cannot find plugin
|
||||
try { // Throw error if cannot find plugin
|
||||
fs.accessSync('./dist/plugins/' + p);
|
||||
} catch (err) {
|
||||
throw new Error('Cannot find plugin "' + p + '"');
|
||||
}
|
||||
serv.addPlugin(p, require('../../plugins/' + p), settings.plugins[p]);
|
||||
return;
|
||||
}
|
||||
serv.addPlugin(p, require(p), settings.plugins[p]);
|
||||
}
|
||||
|
||||
for (var p in serv.plugins) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue