當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript app-builder.compose函數代碼示例

本文整理匯總了TypeScript中app-builder.compose函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript compose函數的具體用法?TypeScript compose怎麽用?TypeScript compose使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了compose函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: compile

async function compile(
  compilerOptions?: Partial<NexeOptions>,
  callback?: (err: Error | null) => void
) {
  let error = null,
    options: NexeOptions | null = null,
    compiler: NexeCompiler | null = null

  try {
    options = normalizeOptions(compilerOptions)
    compiler = new NexeCompiler(options)
    await compose(
      clean,
      resource,
      cli,
      bundle,
      shim,
      download,
      options.build ? [artifacts, ...patches, ...(options.patches as NexePatch[])] : [],
      options.plugins as NexePatch[]
    )(compiler)
  } catch (e) {
    error = e
  }

  if (error) {
    compiler && compiler.quit(error)
    if (callback) return callback(error)
    return Promise.reject(error)
  }

  if (callback) callback(null)
}
開發者ID:jaredallard,項目名稱:nexe,代碼行數:33,代碼來源:nexe.ts

示例2: compile

async function compile(
  compilerOptions?: Partial<NexeOptions>,
  callback?: (err: Error | null) => void
) {
  const options = normalizeOptions(compilerOptions)
  const compiler = new NexeCompiler(options)
  const build = compiler.options.build

  if (options.clean) {
    let path = compiler.src
    if (!options.build) {
      path = compiler.getNodeExecutableLocation(compiler.options.targets[0] as NexeTarget)
    }
    const step = compiler.log.step('Cleaning up nexe build artifacts...')
    step.log(`Deleting contents at: ${path}`)
    await rimrafAsync(path)
    step.log(`Deleted contents at: ${path}`)
    return compiler.quit()
  }

  const buildSteps = build
    ? [download, artifacts, ...patches, ...(options.patches as NexePatch[])]
    : []
  const nexe = compose(resource, bundle, shim, cli, buildSteps, options.plugins as NexePatch[])
  let error = null

  try {
    await nexe(compiler)
  } catch (e) {
    error = e
  }

  if (error) {
    if (compiler.options.loglevel !== 'silent' && error) {
      process.stderr.write(EOL + error.stack + EOL)
    }
    compiler.quit()
    if (callback) return callback(error)
    return Promise.reject(error)
  }
  if (callback) callback(null)
}
開發者ID:zavarat,項目名稱:nexe,代碼行數:42,代碼來源:nexe.ts

示例3: derivePaths

export function createHandler<T extends RouterContext<T>>(
  source: RouteMetadata,
  baseUrl: string = '/',
  derivePaths: (baseUrl: string, route: RouteMetadata) => { [method: string]: string[] } = getPaths,
  typeConverters: TypeConverter<any>[]
) {
  const paths = derivePaths(baseUrl, source),
    paramAnnotations = source.parameterAnnotations.length
      ? source.parameterAnnotations
      : [undefined],
    paramResolvers = paramAnnotations
      .map(extractParameter)
      .map((x, i) => convertType(x, i, source, typeConverters))

  let handlerRef: any
  const handler = {
    path: '',
    withPath,
    source,
    baseUrl,
    convertType,
    paths,
    typeConverters,
    controller: source.controller,
    controllerMethod: source.name,
    paramAnnotations,
    paramResolvers,
    invokeAsync: compose<T>([
      extractBodyParser(source),
      ...extractMiddleware<T>(source),
      resolveRouteMiddleware({
        controller: source.controller,
        controllerMethod: source.name,
        paramResolvers
      })
    ]),
    handler: handlerRef as Handler<T> // hack for defining circular literal
  }
  handler.handler = handler
  return handler
}
開發者ID:calebboyd,項目名稱:ingress,代碼行數:41,代碼來源:handler.ts


注:本文中的app-builder.compose函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。