Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _loadProvider (providerPath: string) {
const provider = tsRequire(providerPath)
return new provider(this.ioc)
}
private _autoload (namespace: string) {
const baseNamespace = this.getAutoloadBaseNamespace(namespace)!
const cacheEntry = this._autoloadsCache.get(namespace)
this.tracer.in(namespace, !!cacheEntry)
/**
* Require the module and cache it
*/
if (!cacheEntry) {
const absPath = this._makeRequirePath(baseNamespace, namespace)
const importValue = tsRequire(absPath)
this._autoloadsCache.set(namespace, { diskPath: absPath, cachedValue: importValue })
}
this.tracer.out()
return this._autoloadsCache.get(namespace)!.cachedValue
}
private _require (filePath: string, optional = false): any | null {
try {
return tsRequire(filePath)
} catch (error) {
if (['MODULE_NOT_FOUND', 'ENOENT'].indexOf(error.code) > -1 && optional) {
return null
}
throw error
}
}