-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cli parameter:
--nocolor
, disable color in cli
- Loading branch information
Showing
9 changed files
with
101 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,25 +2,27 @@ | |
* Copyright (c) 2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
var formatter = { | ||
onFileHint: function(result){ | ||
result.messages.forEach(function (message) { | ||
var compactFormatter = function(formatter, HTMLHint, options){ | ||
var nocolor = options.nocolor; | ||
formatter.on('file', function(event){ | ||
event.messages.forEach(function (message) { | ||
console.log('%s: line %d, col %d, %s - %s (%s)', | ||
result.file, | ||
event.file, | ||
message.line, | ||
message.col, | ||
message.type, | ||
message.message, | ||
message.rule.id | ||
); | ||
); | ||
}); | ||
}, | ||
onEnd: function(hintInfo){ | ||
var allHintCount = hintInfo.allHintCount; | ||
}); | ||
formatter.on('end', function(event){ | ||
var allHintCount = event.allHintCount; | ||
if(allHintCount > 0){ | ||
console.log(''); | ||
console.log('%d problems', hintInfo.allHintCount); | ||
var message = '%d problems'; | ||
console.log(nocolor ? message : message.red, event.allHintCount); | ||
} | ||
} | ||
}); | ||
}; | ||
module.exports = formatter; | ||
module.exports = compactFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,36 +2,42 @@ | |
* Copyright (c) 2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
var formatter = { | ||
onStart: function(){ | ||
var defaultFormatter = function(formatter, HTMLHint, options){ | ||
var nocolor = options.nocolor; | ||
formatter.on('start', function(){ | ||
console.log(''); | ||
}, | ||
onConfigLoaded: function(config, configPath){ | ||
console.log(' Config loaded: %s', configPath.cyan); | ||
}); | ||
formatter.on('config', function(event){ | ||
var configPath = event.configPath; | ||
console.log(' Config loaded: %s', nocolor ? configPath : configPath.cyan); | ||
console.log(''); | ||
}, | ||
onFileHint: function(result, HTMLHint){ | ||
console.log(' '+result.file.white); | ||
var arrLogs = HTMLHint.format(result.messages, { | ||
colors: true, | ||
}); | ||
formatter.on('file', function(event){ | ||
console.log(' '+event.file.white); | ||
var arrLogs = HTMLHint.format(event.messages, { | ||
colors: nocolor ? false : true, | ||
indent: 6 | ||
}); | ||
arrLogs.forEach(function(str){ | ||
console.log(str); | ||
}); | ||
console.log(''); | ||
}, | ||
onEnd: function(hintInfo){ | ||
var allFileCount = hintInfo.allFileCount; | ||
var allHintCount = hintInfo.allHintCount; | ||
var allHintFileCount = hintInfo.allHintFileCount; | ||
var time = hintInfo.time; | ||
}); | ||
formatter.on('end', function(event){ | ||
var allFileCount = event.allFileCount; | ||
var allHintCount = event.allHintCount; | ||
var allHintFileCount = event.allHintFileCount; | ||
var time = event.time; | ||
var message; | ||
if(allHintCount > 0){ | ||
console.log('Scan %d files, found %d errors in %d files (%d ms)'.red, allFileCount, allHintCount, allHintFileCount, time); | ||
message = 'Scan %d files, found %d errors in %d files (%d ms)'; | ||
console.log(nocolor ? message : message.red, allFileCount, allHintCount, allHintFileCount, time); | ||
} | ||
else{ | ||
console.log('Scan %d files, without errors (%d ms).'.green, allFileCount, time); | ||
message = 'Scan %d files, without errors (%d ms).'; | ||
console.log(nocolor ? message : message.green, allFileCount, time); | ||
} | ||
} | ||
}); | ||
}; | ||
module.exports = formatter; | ||
|
||
module.exports = defaultFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
* Copyright (c) 2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
var formatter = { | ||
onEnd: function(hintInfo){ | ||
console.log(JSON.stringify(hintInfo.arrAllMessages)); | ||
} | ||
var jsonFormatter = function(formatter, HTMLHint, options){ | ||
formatter.on('end', function(event){ | ||
console.log(JSON.stringify(event.arrAllMessages)); | ||
}); | ||
}; | ||
module.exports = formatter; | ||
module.exports = jsonFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
* Copyright (c) 2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
var formatter = { | ||
onEnd: function(hintInfo, HTMLHint){ | ||
var markdownFormatter = function(formatter, HTMLHint, options){ | ||
formatter.on('end', function(event){ | ||
console.log('# TOC'); | ||
var arrToc = []; | ||
var arrContents = []; | ||
var arrAllMessages = hintInfo.arrAllMessages; | ||
var arrAllMessages = event.arrAllMessages; | ||
arrAllMessages.forEach(function(fileInfo){ | ||
var filePath = fileInfo.file; | ||
var arrMessages = fileInfo.messages; | ||
|
@@ -35,6 +35,6 @@ var formatter = { | |
}); | ||
console.log(arrToc.join('\r\n')+'\r\n'); | ||
console.log(arrContents.join('\r\n')); | ||
} | ||
}); | ||
}; | ||
module.exports = formatter; | ||
module.exports = markdownFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,25 @@ | |
* Copyright (c) 2015, Yanis Wang <[email protected]> | ||
* MIT Licensed | ||
*/ | ||
var formatter = { | ||
onFileHint: function(result){ | ||
result.messages.forEach(function (message) { | ||
var unixFormatter = function(formatter, HTMLHint, options){ | ||
var nocolor = options.nocolor; | ||
formatter.on('file', function(event){ | ||
event.messages.forEach(function (message) { | ||
console.log([ | ||
result.file, | ||
event.file, | ||
message.line, | ||
message.col, | ||
" " + message.message + ' ['+message.type+'/'+message.rule.id+']' | ||
].join(":")); | ||
}); | ||
}, | ||
onEnd: function(hintInfo){ | ||
var allHintCount = hintInfo.allHintCount; | ||
}); | ||
formatter.on('end', function(event){ | ||
var allHintCount = event.allHintCount; | ||
if(allHintCount > 0){ | ||
console.log(''); | ||
console.log('%d problems', hintInfo.allHintCount); | ||
var message = '%d problems'; | ||
console.log(nocolor ? message : message.red, event.allHintCount); | ||
} | ||
} | ||
}); | ||
}; | ||
module.exports = formatter; | ||
module.exports = unixFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters