Skip to content

Commit

Permalink
console颜色插件colors替换成chalk,API更易容
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhaoboris committed Aug 10, 2015
1 parent 3caa918 commit 77ff7eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
22 changes: 7 additions & 15 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ var exec = require('child_process').exec;
var fs = require('fs');
var co = require('co');
var cheerio = require('cheerio');
var colors = require('colors');
var chalk = require('chalk');
var cfg = require('./config');
var pathReg = cfg.pathReg;
var replaceTo = cfg.replaceTo;
var results = [];
var $ = null;

// 设置console输出颜色
colors.setTheme({
error: 'red',
warn: 'yellow',
info: 'cyan',
success: 'green'
});

/**
* 获取SVN日志记录
* @param {String} command svn log命令
Expand Down Expand Up @@ -111,24 +103,24 @@ function outputPatch(content) {


co(function* () {
console.log('正在向 SVN 服务器获取日志记录......'.info);
console.log( chalk.cyan('正在向 SVN 服务器获取日志记录......') );
return yield getSvnLog(cfg.command);
})
.then(function(content) {
console.log('日志获取成功......'.success);
console.log('开始处理数据......'.info);
console.log( chalk.green('日志获取成功......') );
console.log( chalk.cyan('开始处理数据......') );
$ = toJqueryLike(content);
var logs = findLogsByUser(cfg.user);
var commitsCnt = parseToMailContent(logs);
return Promise.resolve(commitsCnt);
})
.then(function(content) {
console.log('正在输出邮件内容......'.info);
console.log( chalk.cyan('正在输出邮件内容......') );
outputPatch(content);
})
.then(function() {
console.log('任务完成!'.success);
console.log( chalk.green('任务完成!') );
})
.catch(function(err) {
console.log(String(err.stack).error);
console.log( chalk.red(err.stack) );
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "开发环境下需要打包提交的文件路径转换成生产环境的路径",
"author": "Boris <[email protected]>",
"dependencies": {
"chalk": "^1.1.0",
"cheerio": "^0.19.0",
"co": "^4.6.0",
"colors": "^1.1.2"
"co": "^4.6.0"
}
}

0 comments on commit 77ff7eb

Please sign in to comment.