improve figlet coloring
This commit is contained in:
parent
cbfc000f7c
commit
e705141f6d
8
dist/beautylog.figlet.d.ts
vendored
8
dist/beautylog.figlet.d.ts
vendored
@ -1,3 +1,9 @@
|
|||||||
import 'typings-global';
|
import 'typings-global';
|
||||||
|
import plugins = require('./beautylog.plugins');
|
||||||
|
export interface IFigletOptions {
|
||||||
|
font?: string;
|
||||||
|
color?: plugins.beautycolor.TColorName;
|
||||||
|
cb?: any;
|
||||||
|
}
|
||||||
export declare let figlet: (textArg: string, optionsArg?: any) => Promise<{}>;
|
export declare let figlet: (textArg: string, optionsArg?: any) => Promise<{}>;
|
||||||
export declare let figletSync: (textArg: string, optionsArg?: any) => boolean;
|
export declare let figletSync: (textArg: string, optionsArg?: IFigletOptions) => boolean;
|
||||||
|
18
dist/beautylog.figlet.js
vendored
18
dist/beautylog.figlet.js
vendored
@ -20,7 +20,7 @@ exports.figlet = function (textArg, optionsArg) {
|
|||||||
console.dir(err);
|
console.dir(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(data[options.color]);
|
console.log(colorFiglet(data, optionsArg.color));
|
||||||
options.cb();
|
options.cb();
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
@ -29,11 +29,21 @@ exports.figlet = function (textArg, optionsArg) {
|
|||||||
exports.figletSync = function (textArg, optionsArg) {
|
exports.figletSync = function (textArg, optionsArg) {
|
||||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
|
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
|
||||||
let options = plugins.lodash.assign(mergeOptions, optionsArg);
|
let options = plugins.lodash.assign(mergeOptions, optionsArg);
|
||||||
console.log(plugins.figlet.textSync(textArg, {
|
let figletString = plugins.figlet.textSync(textArg, {
|
||||||
font: options.font,
|
font: options.font,
|
||||||
horizontalLayout: 'default',
|
horizontalLayout: 'default',
|
||||||
verticalLayout: 'default'
|
verticalLayout: 'default'
|
||||||
})[options.color]);
|
});
|
||||||
|
console.log(col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UMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQ2hCLE1BQU0sQ0FBQTtRQUNWLENBQUM7UUFDRCxPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQTtRQUNoQyxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUE7UUFDWixJQUFJLENBQUMsT0FBTyxFQUFFLENBQUE7SUFDbEIsQ0FBQyxDQUNKLENBQUE7SUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUN2QixDQUFDLENBQUE7QUFFVSxRQUFBLFVBQVUsR0FBRyxVQUFTLE9BQWUsRUFBQyxVQUFXO0lBQ3hELElBQUksWUFBWSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQyxDQUFBO0lBQzNELElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLFlBQVksRUFBQyxVQUFVLENBQUMsQ0FBQTtJQUM1RCxPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLE9BQU8sRUFBQztRQUN4QyxJQUFJLEVBQUUsT0FBTyxDQUFDLElBQUk7UUFDbEIsZ0JBQWdCLEVBQUUsU0FBUztRQUMzQixjQUFjLEVBQUUsU0FBUztLQUM1QixDQUFDLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUE7SUFDbEIsTUFBTSxDQUFDLElBQUksQ0FBQTtBQUNmLENBQUMsQ0FBQSJ9
|
let colorFiglet = (figletStringArg, colorArg) => {
|
||||||
|
let figletArray = figletStringArg.split('\n');
|
||||||
|
let figletStringCombined = '';
|
||||||
|
for (let figletRow of figletArray) {
|
||||||
|
figletRow = plugins.beautycolor.coloredString(figletRow, colorArg);
|
||||||
|
figletStringCombined = figletStringCombined + figlet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QUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUM3QyxJQUFJLG9CQUFvQixHQUFHLEVBQUUsQ0FBQTtJQUM3QixHQUFHLENBQUMsQ0FBQyxJQUFJLFNBQVMsSUFBSSxXQUFZLENBQUMsQ0FBQyxDQUFDO1FBQ2pDLFNBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLGFBQWEsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLENBQUE7UUFDbEUsb0JBQW9CLEdBQUcsb0JBQW9CLEdBQUcsU0FBUyxHQUFHLElBQUksQ0FBQTtJQUNsRSxDQUFDO0lBQ0QsTUFBTSxDQUFDLG9CQUFvQixDQUFBO0FBQy9CLENBQUMsQ0FBQSJ9
|
@ -19,7 +19,7 @@ describe('beautylog', function () {
|
|||||||
});
|
});
|
||||||
describe('.figlet', function () {
|
describe('.figlet', function () {
|
||||||
it('should print nice fonts to console in yellow', function (done) {
|
it('should print nice fonts to console in yellow', function (done) {
|
||||||
beautylog.figlet('Async!', { font: 'Star Wars', color: 'yellow' }).then(done);
|
beautylog.figlet('Async!', { font: 'Star Wars', color: 'orange' }).then(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('.figletSync', function () {
|
describe('.figletSync', function () {
|
||||||
|
@ -21,7 +21,7 @@ describe('beautylog',function(){
|
|||||||
})
|
})
|
||||||
describe('.figlet',function(){
|
describe('.figlet',function(){
|
||||||
it('should print nice fonts to console in yellow',function(done){
|
it('should print nice fonts to console in yellow',function(done){
|
||||||
beautylog.figlet('Async!',{font: 'Star Wars',color: 'yellow'}).then(done)
|
beautylog.figlet('Async!',{font: 'Star Wars',color: 'orange'}).then(done)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('.figletSync',function(){
|
describe('.figletSync',function(){
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import 'typings-global'
|
import 'typings-global'
|
||||||
import plugins = require('./beautylog.plugins')
|
import plugins = require('./beautylog.plugins')
|
||||||
let defaultOptions = {
|
|
||||||
|
export interface IFigletOptions {
|
||||||
|
font?: string
|
||||||
|
color?: plugins.beautycolor.TColorName
|
||||||
|
cb?
|
||||||
|
}
|
||||||
|
|
||||||
|
let defaultOptions: IFigletOptions = {
|
||||||
font: 'Star Wars',
|
font: 'Star Wars',
|
||||||
color: 'green',
|
color: 'green',
|
||||||
cb: function() {}
|
cb: function() {}
|
||||||
@ -17,13 +24,13 @@ export let figlet = function(textArg: string, optionsArg?){
|
|||||||
horizontalLayout: 'default',
|
horizontalLayout: 'default',
|
||||||
verticalLayout: 'default'
|
verticalLayout: 'default'
|
||||||
},
|
},
|
||||||
function(err, data) {
|
function(err, data: string) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Something went wrong...')
|
console.log('Something went wrong...')
|
||||||
console.dir(err)
|
console.dir(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(data[options.color])
|
console.log(colorFiglet(data, optionsArg.color))
|
||||||
options.cb()
|
options.cb()
|
||||||
done.resolve()
|
done.resolve()
|
||||||
}
|
}
|
||||||
@ -31,13 +38,24 @@ export let figlet = function(textArg: string, optionsArg?){
|
|||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
export let figletSync = function(textArg: string,optionsArg?){
|
export let figletSync = function(textArg: string,optionsArg?: IFigletOptions){
|
||||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
||||||
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
||||||
console.log(plugins.figlet.textSync(textArg,{
|
let figletString: string = plugins.figlet.textSync(textArg,{
|
||||||
font: options.font,
|
font: options.font,
|
||||||
horizontalLayout: 'default',
|
horizontalLayout: 'default',
|
||||||
verticalLayout: 'default'
|
verticalLayout: 'default'
|
||||||
})[options.color])
|
})
|
||||||
|
console.log(colorFiglet(figletString, optionsArg.color))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let colorFiglet = (figletStringArg, colorArg: plugins.beautycolor.TColorName) => {
|
||||||
|
let figletArray = figletStringArg.split('\n')
|
||||||
|
let figletStringCombined = ''
|
||||||
|
for (let figletRow of figletArray ) {
|
||||||
|
figletRow = plugins.beautycolor.coloredString(figletRow, colorArg)
|
||||||
|
figletStringCombined = figletStringCombined + figletRow + '\n'
|
||||||
|
}
|
||||||
|
return figletStringCombined
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user