本文整理汇总了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)
}
示例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)
}
示例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
}