How to use the @poppinss/utils.resolveFrom function in @poppinss/utils

To help you get started, we’ve selected a few @poppinss/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 / src / Ignitor / Ace / CoreCommands.ts View on Github external
public async handle (argv: string[]) {
    this.setupApplication()
    await this.importAssembler(argv[0])

    const manifest = new this.ace.Manifest(dirname(resolveFrom(this.appRoot, '@adonisjs/assembler')))
    const kernel = new this.ace.Kernel(this.application)

    /**
     * Showing commands help
     */
    kernel.flag('help', async (value, _, command) => {
      if (!value) {
        return
      }

      kernel.printHelp(command)
      process.exit(0)
    }, { alias: 'h' })

    kernel.useManifest(manifest)
    await kernel.handle(argv)
github adonisjs / assembler / src / RcFile / index.ts View on Github external
import slash from 'slash'
import picomatch from 'picomatch'
import { join, relative } from 'path'
import { Ioc } from '@adonisjs/fold'
import importFresh from 'import-fresh'
import { resolveFrom } from '@poppinss/utils'
import { Application } from '@adonisjs/application/build/standalone'

import { RCFILE_NAME, ACE_FILE_NAME } from '../../config/paths'

/**
 * Exposes the API to pull meta files from the `.adonisrc.json` file and
 * also match relative file paths against the defined globs.
 */
export class RcFile {
  public rcFilePath = resolveFrom(this.appRoot, `./${RCFILE_NAME}`)

  /**
   * Raw rcfile contents
   */
  public raw = this.getDiskContents()

  /**
   * Reference to application
   */
  public application = new Application(this.appRoot, new Ioc(), this.raw, {})

  /**
   * A matcher to know if a file is part of the meta files globs
   */
  public isMetaFile: (filePath: string) => boolean = picomatch(this.getMetaFilesGlob())
github adonisjs / fold / src / Registrar / index.ts View on Github external
private loadProvider (providerPath: string) {
    providerPath = this.basePath ? resolveFrom(this.basePath, providerPath) : providerPath
    const provider = esmRequire(providerPath)

    if (typeof (provider) !== 'function') {
      throw new Error(`Make sure export default the provider from ${providerPath}`)
    }

    return new provider(this.ioc)
  }
github adonisjs / adonis-framework / src / utils / index.ts View on Github external
export function optionalResolveAndRequire (
  filePath: string,
  fromPath: string,
  optional = false,
): any | null {
  try {
    return optionalRequire(resolveFrom(fromPath, filePath))
  } catch (error) {
    if (isMissingModuleError(error) && optional) {
      return null
    }

    throw error
  }
}
github adonisjs / assembler / src / Compiler / index.ts View on Github external
SERVER_ENTRY_FILE,
  DEFAULT_BUILD_DIR,
} from '../../config/paths'

/**
 * Exposes the API to build the AdonisJs project for development or
 * production. The production build has it's own set of node_modules
 */
export class Compiler {
  /**
   * Reference to typescript compiler
   */
  public tsCompiler = new TypescriptCompiler(
    this.appRoot,
    TSCONFIG_FILE_NAME,
    require(resolveFrom(this.appRoot, 'typescript/lib/typescript')),
  )

  /**
   * Reference to HTTP server
   */
  public httpServer: HttpServer | DummyHttpServer

  /**
   * Reference to rc File
   */
  public rcFile = new RcFile(this.appRoot)

  /**
   * Manifest instance to generate ace manifest file
   */
  public manifest = new Manifest(this.appRoot, this.logger)

@poppinss/utils

Handy utilities for repetitive work

MIT
Latest version published 2 months ago

Package Health Score

79 / 100
Full package analysis