2016-10-16 00:26:43 +00:00
|
|
|
import 'typings-global'
|
|
|
|
import plugins = require('./beautylog.plugins')
|
|
|
|
let defaultOptions = {
|
|
|
|
font: 'Star Wars',
|
|
|
|
color: 'green',
|
|
|
|
cb: function() {}
|
|
|
|
}
|
2016-05-02 00:23:40 +00:00
|
|
|
|
2017-01-21 00:05:28 +00:00
|
|
|
export let figlet = function(textArg: string, optionsArg?){
|
2016-10-16 00:26:43 +00:00
|
|
|
let done = plugins.q.defer()
|
|
|
|
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
|
|
|
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
2017-01-21 00:05:28 +00:00
|
|
|
plugins.figlet(
|
|
|
|
textArg,
|
|
|
|
{
|
|
|
|
font: options.font,
|
|
|
|
horizontalLayout: 'default',
|
|
|
|
verticalLayout: 'default'
|
|
|
|
},
|
|
|
|
function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
console.log('Something went wrong...')
|
|
|
|
console.dir(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
console.log(data[options.color])
|
|
|
|
options.cb()
|
|
|
|
done.resolve()
|
2016-02-23 13:34:40 +00:00
|
|
|
}
|
2017-01-21 00:05:28 +00:00
|
|
|
)
|
2016-10-16 00:26:43 +00:00
|
|
|
return done.promise
|
|
|
|
}
|
2016-05-02 00:23:40 +00:00
|
|
|
|
2016-10-16 00:26:43 +00:00
|
|
|
export let figletSync = function(textArg: string,optionsArg?){
|
|
|
|
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
|
|
|
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
2016-02-23 13:34:40 +00:00
|
|
|
console.log(plugins.figlet.textSync(textArg,{
|
|
|
|
font: options.font,
|
|
|
|
horizontalLayout: 'default',
|
|
|
|
verticalLayout: 'default'
|
2016-10-16 00:26:43 +00:00
|
|
|
})[options.color])
|
|
|
|
return true
|
|
|
|
}
|