Make logInline treat nullish values as an empty string.

This commit is contained in:
John-David Dalton
2014-05-01 00:22:03 -07:00
parent 6f4c7ca171
commit 04160e6acc

View File

@@ -287,7 +287,7 @@
* Writes an inline message to standard output. * Writes an inline message to standard output.
* *
* @private * @private
* @param {string} text The text to log. * @param {string} [text=''] The text to log.
*/ */
var logInline = (function() { var logInline = (function() {
// exit early if not Node.js // exit early if not Node.js
@@ -297,13 +297,16 @@
} }
// cleanup any inline logs when exited via `ctrl+c` // cleanup any inline logs when exited via `ctrl+c`
process.on('SIGINT', function() { process.on('SIGINT', function() {
logInline(''); logInline();
process.exit(); process.exit();
}); });
var prevLine = ''; var prevLine = '';
return function(text) { return function(text) {
var blankLine = repeat(' ', prevLine.length); var blankLine = repeat(' ', prevLine.length);
if (text == null) {
text = '';
}
if (text.length > hr.length) { if (text.length > hr.length) {
text = text.slice(0, hr.length - 3) + '...'; text = text.slice(0, hr.length - 3) + '...';
} }
@@ -457,7 +460,7 @@
var failures = details.failed; var failures = details.failed;
var statusColor = failures ? 'magenta' : 'green'; var statusColor = failures ? 'magenta' : 'green';
logInline(''); logInline();
console.log(hr); console.log(hr);
console.log(color(statusColor, ' PASS: ' + details.passed + ' FAIL: ' + failures + ' TOTAL: ' + details.total)); console.log(color(statusColor, ' PASS: ' + details.passed + ' FAIL: ' + failures + ' TOTAL: ' + details.total));
console.log(color(statusColor, ' Finished in ' + details.runtime + ' milliseconds.')); console.log(color(statusColor, ' Finished in ' + details.runtime + ' milliseconds.'));
@@ -511,7 +514,7 @@
if (hidepassed && !failures) { if (hidepassed && !failures) {
return; return;
} }
logInline(''); logInline();
if (!modulePrinted) { if (!modulePrinted) {
modulePrinted = true; modulePrinted = true;
console.log(hr); console.log(hr);