How to use the @adonisjs/utils.tsRequire function in @adonisjs/utils

To help you get started, we’ve selected a few @adonisjs/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / adonis-framework / packages / fold / src / Registrar / index.ts View on Github external
private _loadProvider (providerPath: string) {
    const provider = tsRequire(providerPath)
    return new provider(this.ioc)
  }
github adonisjs / adonis-framework / packages / fold / src / Ioc / index.ts View on Github external
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
  }
github adonisjs / adonis-framework / packages / core / src / Ignitor / index.ts View on Github external
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
    }
  }

@adonisjs/utils

A collection of utilities to keep AdonisJs codebase dry

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis