Skip to content

Commit

Permalink
fix: #9730, show warning if plugin is active but not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Aug 24, 2021
1 parent 096c5a5 commit 13878e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/plugins/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ const Data = module.exports;
const basePath = path.join(__dirname, '../../');

Data.getPluginPaths = async function () {
let plugins = await db.getSortedSetRange('plugins:active', 0, -1);
plugins = plugins.filter(plugin => plugin && typeof plugin === 'string')
const plugins = await db.getSortedSetRange('plugins:active', 0, -1);
const pluginPaths = plugins.filter(plugin => plugin && typeof plugin === 'string')
.map(plugin => path.join(paths.nodeModules, plugin));

const exists = await Promise.all(plugins.map(p => file.exists(p)));
const exists = await Promise.all(pluginPaths.map(file.exists));
exists.forEach((exists, i) => {
if (!exists) {
winston.warn(`[plugins] "${plugins[i]}" is active but not installed.`);
}
});
return plugins.filter((p, i) => exists[i]);
};

Expand Down
4 changes: 3 additions & 1 deletion src/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Upgrade.appendPluginScripts = async function (files) {
});
}
} catch (e) {
winston.warn(`[upgrade/appendPluginScripts] Unable to read plugin.json for plugin \`${plugin}\`. Skipping.`);
if (e.code !== 'MODULE_NOT_FOUND') {
winston.error(e.stack);
}
}
});
return files;
Expand Down

0 comments on commit 13878e9

Please sign in to comment.