const fs=require("fs"),path=require("path"),BuiltinModule=require("module"),{getRealWorkspace:getRealWorkspace}=require("./utils"),Module=module.constructor.length>1?module.constructor:BuiltinModule,oldNodeModulePaths=Module._nodeModulePaths,commonDirs=[],commonDirPath=path.resolve(getRealWorkspace(),`uniCloud-${process.env.UNICLOUD_SPACE_PROVIDER}`,"cloudfunctions","common"),uniModulesDirPath=path.resolve(getRealWorkspace(),"uni_modules");if(fs.existsSync(commonDirPath)&&commonDirs.push(commonDirPath),fs.existsSync(uniModulesDirPath)){fs.readdirSync(uniModulesDirPath).forEach((o=>{const e=path.resolve(uniModulesDirPath,o,"uniCloud","cloudfunctions","common");fs.existsSync(e)&&commonDirs.push(e)}))}commonDirs.length&&(Module._nodeModulePaths=function(o){const e=oldNodeModulePaths.call(this,o);return e.push(...commonDirs),e});