2021-12-12 14:51:29 +00:00
|
|
|
const { readdirSync } = require('fs');
|
|
|
|
const { join } = require('path');
|
|
|
|
const NodeModule = require('module');
|
|
|
|
|
|
|
|
const paths = require('../paths');
|
2021-12-12 14:41:15 +00:00
|
|
|
|
|
|
|
|
2022-01-29 11:21:05 +00:00
|
|
|
module.exports = (moduleName) => {
|
2021-12-12 14:51:29 +00:00
|
|
|
const modulesDir = join(paths.getExeDir(), 'modules');
|
2021-12-12 22:45:58 +00:00
|
|
|
const moduleDirs = readdirSync(modulesDir);
|
2021-12-12 14:51:29 +00:00
|
|
|
|
2022-01-29 11:21:05 +00:00
|
|
|
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
|
2021-12-12 22:45:58 +00:00
|
|
|
|
2022-01-29 11:21:05 +00:00
|
|
|
for (const dir of moduleDirs) { // General (load all)
|
2021-12-12 22:45:58 +00:00
|
|
|
NodeModule.globalPaths.push(join(modulesDir, dir));
|
|
|
|
}
|
2021-12-12 14:41:15 +00:00
|
|
|
};
|