added test and fixed an error

This commit is contained in:
Phil Kunz 2015-09-26 20:46:16 +02:00
parent 7bd46ad13e
commit 959fd9004a
6 changed files with 56 additions and 12 deletions

View File

@ -1,6 +1,5 @@
/// <reference path="./typings/tsd.d.ts" />
var colors = require("colors");
var through = require("through2");
var bl;
bl = {};
/**
@ -9,8 +8,9 @@ bl = {};
*/
var localBl;
localBl = {};
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
localBl.successPrefix = ' Success: '.bgGreen.white.bold;
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
/**
*
* @param logText
@ -23,13 +23,13 @@ bl.log = function (logText, logType) {
try {
switch (logType) {
case 'normal':
logText.cyan.bold;
logText = localBl.normalPrefix + logText.cyan.bold;
break;
case 'error':
logText = localBl.errorPrefix + logText.red.bold;
break;
case 'success':
logText = localBl.successPrefix + logText.cyan.bold;
logText = localBl.successPrefix + logText.green.bold;
break;
default:
logText.blue.bold;

View File

@ -23,6 +23,6 @@
},
"homepage": "https://github.com/pushrocks/beautylog",
"dependencies": {
"beautylog": "latest"
"colors": "latest"
}
}

15
test.js Normal file
View File

@ -0,0 +1,15 @@
/// <reference path="./typings/tsd.d.ts" />
var beautyLog = require('./index.js');
console.log('*** start test ***');
console.log('');
console.log('declarative function calls:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.error('beautylog.error(), with normal logText, without logType');
beautyLog.success('beautylog.success(), with normal logText, without logType');
console.log('');
console.log('logType String:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.log('beautylog.log(), with normal logText, with logType "error"', 'error');
beautyLog.log('beautylog.log(), with normal logText, with logType "success"', 'success');
console.log('');
console.log('*** end test ***');

View File

@ -11,6 +11,15 @@ gulp.task('compileTS', function() {
return stream;
});
gulp.task('default',['compileTS'], function() {
gulp.task('compileTSTest', function() {
var stream = gulp.src('../test.ts')
.pipe(gulpTypescript({
out: "test.js"
}))
.pipe(gulp.dest("../../"));
return stream;
});
gulp.task('default',['compileTS','compileTSTest'], function() {
console.log('Typescript compiled');
});

View File

@ -1,6 +1,5 @@
/// <reference path="./typings/tsd.d.ts" />
var colors = require("colors");
var through = require("through2");
var bl:any;
@ -12,8 +11,9 @@ bl = {}
*/
var localBl:any;
localBl = {};
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
localBl.successPrefix = ' Success: '.bgGreen.white.bold;
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
/**
*
@ -25,13 +25,13 @@ bl.log = (logText:string = 'empty log',logType:string = 'normal') => {
try {
switch (logType) {
case 'normal':
logText.cyan.bold;
logText = localBl.normalPrefix + logText.cyan.bold;
break;
case 'error':
logText = localBl.errorPrefix + logText.red.bold;
break;
case 'success':
logText = localBl.successPrefix + logText.cyan.bold;
logText = localBl.successPrefix + logText.green.bold;
break;
default:
logText.blue.bold;

20
ts/test.ts Normal file
View File

@ -0,0 +1,20 @@
/// <reference path="./typings/tsd.d.ts" />
var beautyLog = require('./index.js');
console.log('*** start test ***');
console.log ('');
console.log('declarative function calls:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.error('beautylog.error(), with normal logText, without logType');
beautyLog.success('beautylog.success(), with normal logText, without logType');
console.log('');
console.log('logType String:');
beautyLog.log('beautylog.log(), with normal logText, without logType');
beautyLog.log('beautylog.log(), with normal logText, with logType "error"','error');
beautyLog.log('beautylog.log(), with normal logText, with logType "success"','success');
console.log ('');
console.log('*** end test ***');