本文整理汇总了TypeScript中typings-core.Emitter.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Emitter.on方法的具体用法?TypeScript Emitter.on怎么用?TypeScript Emitter.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typings-core.Emitter
的用法示例。
在下文中一共展示了Emitter.on方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: EventEmitter
})
const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })
// Notify the user of updates.
updateNotifier({ pkg }).notify()
// Execute with normalizations applied.
exec(args)
// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
logWarning(`Path "${path}" is missing`, 'enoent')
})
// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
logWarning(
`Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
`let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
'hastypings'
)
})
// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
logInfo(`${name}: ${message}`, 'postmessage')
})
示例2: EventEmitter
})
const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })
// Notify the user of updates.
updateNotifier({ pkg }).notify()
// Execute with normalizations applied.
exec(args)
// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
logWarning(`Path "${path}" is missing`, 'ENOENT')
})
// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
logWarning(
`Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
`let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
'has typings'
)
})
// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
logInfo(message, `${name} postmessage`)
})
示例3: resolve
}
})
const cwd = argv.cwd ? resolve(argv.cwd) : process.cwd()
const emitter: Emitter = new EventEmitter()
const args: Args = extend(argv, { emitter, cwd })
// Notify the user of updates.
updateNotifier({ pkg }).notify()
// Execute with normalizations applied.
exec(args)
// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
logWarning(`Path "${path}" is missing`, 'enoent')
})
// Log warning when typings come packaged.
emitter.on('hastypings', function ({ name, typings }) {
logWarning(
`Typings for "${name}" already exist in "${relative(cwd, typings)}". You should ` +
`let TypeScript resolve the packaged typings and uninstall the copy installed by Typings`,
'hastypings'
)
})
// Emit postmessage events.
emitter.on('postmessage', function ({ message, name }) {
logInfo(`${name}: ${message}`, 'postmessage')
})
示例4: EventEmitter
})
const cwd = process.cwd()
const emitter: Emitter = new EventEmitter()
const isDev = IS_PRODUCTION ? argv.dev : !argv.production
const args: Args = extend({ cwd, emitter }, argv, { dev: isDev, production: !isDev })
// Notify the user of updates.
updateNotifier({ pkg }).notify()
// Execute with normalizations applied.
exec(args)
// Log warnings on enoent events.
emitter.on('enoent', function ({ path }) {
logWarning(`Path "${path}" is missing`, 'ENOENT')
})
/**
* Handle the CLI commands.
*/
function exec (options: Args): any {
if (options._.length) {
const command = ALIASES[options._[0]]
const args = options._.slice(1)
if (command != null) {
if (options.help) {
return handle(command.help(args, options), options)
}