Skip to content

Commit

Permalink
feat(): use winston logging tool
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-linux-new committed Nov 17, 2015
1 parent fd70d21 commit 8871af2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
19 changes: 8 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
// Inspired by: https://github.com/commitizen/cz-conventional-changelog and https://github.com/commitizen/cz-cli

var wrap = require('./node_modules/word-wrap/index');

var SYMLINK_CONFIG_NAME = 'cz-config';
var log = require('winston');


// function logger(arguments) {
function logger() {
console.info(arguments);
}

/* istanbul ignore next */
function readConfigFile() {
// this function is replaced in test.
Expand All @@ -21,8 +16,9 @@ function readConfigFile() {
// This file is a symlink to the real one usually placed in the root of your project.
config = require('./' + SYMLINK_CONFIG_NAME);
} catch (err) {
logger('You don\'t have a file "' + SYMLINK_CONFIG_NAME + '" in your porject root directory. We will use the default configuration file inside this directory: ' + __dirname);
logger('\n\nYou should run "npm run postinstall" to fix it up.');
log.warn('You don\'t have a file "' + SYMLINK_CONFIG_NAME + '" in your porject root directory. We will use the default configuration file inside this directory: ' + __dirname);
log.warn('You should go to your "node_modules/cz-customizable" and run "npm run postinstall" to fix it up. Please report on Github if this doenst work.');

config = require('./cz-config-EXAMPLE');
}
return config;
Expand Down Expand Up @@ -79,7 +75,7 @@ module.exports = {
prompter: function(cz, commit) {
var config = readConfigFile();

logger('\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n');
log.info('\n\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n');

cz.prompt([
{
Expand Down Expand Up @@ -123,18 +119,19 @@ module.exports = {
name: 'confirmCommit',
message: function(answers) {
var SEP = '###--------------------------------------------------------###';
logger('\n' + SEP + '\n' + buildCommit(answers) + '\n' + SEP + '\n');
log.info('\n' + SEP + '\n' + buildCommit(answers) + '\n' + SEP + '\n');
return 'Are you sure you want to proceed with the commit above?';
}
}
], function(answers) {
if (!answers.confirmCommit) {
logger('Commit has been canceled.');
log.info('Commit has been canceled.');
return;
}

var commitStr = buildCommit(answers);
commit(commitStr);
// log.info('<<< this is dry run >>>');
});
}
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"istanbul": "0.4.0",
"jasmine-node": "1.14.5",
"rewire": "2.4.0",
"semantic-release": "4.3.5"
"semantic-release": "4.3.5",
"winston": "2.1.0"
},
"config": {
"commitizen": {
Expand Down

0 comments on commit 8871af2

Please sign in to comment.