|
|
|
@ -5,18 +5,13 @@ const NodeModule = require('module');
|
|
|
|
|
const paths = require('../paths');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = (moduleName) => { // If undefined, load all
|
|
|
|
|
module.exports = (moduleName) => {
|
|
|
|
|
const modulesDir = join(paths.getExeDir(), 'modules');
|
|
|
|
|
const moduleDirs = readdirSync(modulesDir);
|
|
|
|
|
|
|
|
|
|
if (moduleName) {
|
|
|
|
|
const moduleCoreDir = moduleDirs.find((x) => x.startsWith(moduleName + '-')); // Find desktop core dir by name
|
|
|
|
|
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
|
|
|
|
|
|
|
|
|
|
return NodeModule.globalPaths.push(join(modulesDir, moduleCoreDir)); // Add to globalPaths for requiring
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Undefined moduleName, load all
|
|
|
|
|
for (const dir of moduleDirs) {
|
|
|
|
|
for (const dir of moduleDirs) { // General (load all)
|
|
|
|
|
NodeModule.globalPaths.push(join(modulesDir, dir));
|
|
|
|
|
}
|
|
|
|
|
};
|