added test and fixed an error
This commit is contained in:
parent
7bd46ad13e
commit
959fd9004a
10
index.js
10
index.js
@ -1,6 +1,5 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var colors = require("colors");
|
var colors = require("colors");
|
||||||
var through = require("through2");
|
|
||||||
var bl;
|
var bl;
|
||||||
bl = {};
|
bl = {};
|
||||||
/**
|
/**
|
||||||
@ -9,8 +8,9 @@ bl = {};
|
|||||||
*/
|
*/
|
||||||
var localBl;
|
var localBl;
|
||||||
localBl = {};
|
localBl = {};
|
||||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
|
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
||||||
localBl.successPrefix = ' Success: '.bgGreen.white.bold;
|
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
||||||
|
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param logText
|
* @param logText
|
||||||
@ -23,13 +23,13 @@ bl.log = function (logText, logType) {
|
|||||||
try {
|
try {
|
||||||
switch (logType) {
|
switch (logType) {
|
||||||
case 'normal':
|
case 'normal':
|
||||||
logText.cyan.bold;
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
logText = localBl.errorPrefix + logText.red.bold;
|
logText = localBl.errorPrefix + logText.red.bold;
|
||||||
break;
|
break;
|
||||||
case 'success':
|
case 'success':
|
||||||
logText = localBl.successPrefix + logText.cyan.bold;
|
logText = localBl.successPrefix + logText.green.bold;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logText.blue.bold;
|
logText.blue.bold;
|
||||||
|
@ -23,6 +23,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/beautylog",
|
"homepage": "https://github.com/pushrocks/beautylog",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "latest"
|
"colors": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
test.js
Normal file
15
test.js
Normal 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 ***');
|
@ -11,6 +11,15 @@ gulp.task('compileTS', function() {
|
|||||||
return stream;
|
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');
|
console.log('Typescript compiled');
|
||||||
});
|
});
|
10
ts/index.ts
10
ts/index.ts
@ -1,6 +1,5 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var colors = require("colors");
|
var colors = require("colors");
|
||||||
var through = require("through2");
|
|
||||||
|
|
||||||
|
|
||||||
var bl:any;
|
var bl:any;
|
||||||
@ -12,8 +11,9 @@ bl = {}
|
|||||||
*/
|
*/
|
||||||
var localBl:any;
|
var localBl:any;
|
||||||
localBl = {};
|
localBl = {};
|
||||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
|
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
||||||
localBl.successPrefix = ' Success: '.bgGreen.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 {
|
try {
|
||||||
switch (logType) {
|
switch (logType) {
|
||||||
case 'normal':
|
case 'normal':
|
||||||
logText.cyan.bold;
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
logText = localBl.errorPrefix + logText.red.bold;
|
logText = localBl.errorPrefix + logText.red.bold;
|
||||||
break;
|
break;
|
||||||
case 'success':
|
case 'success':
|
||||||
logText = localBl.successPrefix + logText.cyan.bold;
|
logText = localBl.successPrefix + logText.green.bold;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logText.blue.bold;
|
logText.blue.bold;
|
||||||
|
20
ts/test.ts
Normal file
20
ts/test.ts
Normal 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 ***');
|
Loading…
Reference in New Issue
Block a user