[Utils > u2LoadModulePath] Cleanup source
This commit is contained in:
parent
65058550f2
commit
4f7ce2a3d5
1 changed files with 3 additions and 8 deletions
|
@ -5,18 +5,13 @@ const NodeModule = require('module');
|
||||||
const paths = require('../paths');
|
const paths = require('../paths');
|
||||||
|
|
||||||
|
|
||||||
module.exports = (moduleName) => { // If undefined, load all
|
module.exports = (moduleName) => {
|
||||||
const modulesDir = join(paths.getExeDir(), 'modules');
|
const modulesDir = join(paths.getExeDir(), 'modules');
|
||||||
const moduleDirs = readdirSync(modulesDir);
|
const moduleDirs = readdirSync(modulesDir);
|
||||||
|
|
||||||
if (moduleName) {
|
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
|
||||||
const moduleCoreDir = moduleDirs.find((x) => x.startsWith(moduleName + '-')); // Find desktop core dir by name
|
|
||||||
|
|
||||||
return NodeModule.globalPaths.push(join(modulesDir, moduleCoreDir)); // Add to globalPaths for requiring
|
for (const dir of moduleDirs) { // General (load all)
|
||||||
}
|
|
||||||
|
|
||||||
// Undefined moduleName, load all
|
|
||||||
for (const dir of moduleDirs) {
|
|
||||||
NodeModule.globalPaths.push(join(modulesDir, dir));
|
NodeModule.globalPaths.push(join(modulesDir, dir));
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue