You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OpenAsar-Kernel/src/utils/u2LoadModulePath.js

17 lines
547 B

const { readdirSync } = require('fs');
const { join } = require('path');
const NodeModule = require('module');
const paths = require('../paths');
module.exports = (moduleName) => {
const modulesDir = join(paths.getExeDir(), 'modules');
const moduleDirs = readdirSync(modulesDir);
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
for (const dir of moduleDirs) { // General (load all)
NodeModule.globalPaths.push(join(modulesDir, dir));
}
};