[Pkg-javascript-commits] [node-tap-mocha-reporter] 106/137: Don't raise an error when the screen is super narrow

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:49:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-tap-mocha-reporter.

commit 81b2a193e9de58414292d261ba75095e1ef279d9
Author: isaacs <i at izs.me>
Date:   Wed Jan 25 22:20:44 2017 -0800

    Don't raise an error when the screen is super narrow
    
    Fix tapjs/node-tap#340
---
 lib/reporters/classic.js | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/reporters/classic.js b/lib/reporters/classic.js
index 6efe8b4..09911f5 100644
--- a/lib/reporters/classic.js
+++ b/lib/reporters/classic.js
@@ -12,6 +12,10 @@ var Base = require('./base')
   , uclen = require('unicode-length').get
   , colorSupport = require('color-support')()
 
+function repeat (n, c) {
+  return new Array(Math.max(n + 1, 0)).join(c)
+}
+
 function hasOwnProperty (obj, key) {
   return Object.prototype.hasOwnProperty.call(obj, key)
 }
@@ -158,7 +162,7 @@ function doDiff (found, wanted, palette) {
     return line && i > 4
   }).map(function (line) {
     if (uclen(line) < width)
-      line += new Array(width - uclen(line) + 1).join(' ')
+      line += repeat(width - uclen(line) + 1, ' ')
     return line
   }).map(function (line) {
     if (line.charAt(0) === '+')
@@ -172,12 +176,12 @@ function doDiff (found, wanted, palette) {
   var pref =
     bg + added + '+++ found' +
       (Base.useColors
-        ? new Array(width - '+++ found'.length + 1).join(' ')
+        ? repeat(width - '+++ found'.length + 1, ' ')
         : '') +
       reset + '\n' +
     bg + removed + '--- wanted' +
       (Base.useColors
-        ? new Array(width - '--- wanted'.length + 1).join(' ')
+        ? repeat(width - '--- wanted'.length + 1, ' ')
         : '') +
       reset + '\n'
 
@@ -247,10 +251,10 @@ function Classic (runner) {
     var len = 60
     var title = suite.title || '(unnamed)'
     var num = pass + '/' + total
-    var dots = len - uclen(title) - uclen(num) - 2
-    if (dots < 3)
-      dots = 3
-    dots = ' ' + new Array(dots).join('.') + ' '
+    var dots = len - uclen(title) - uclen(num) - 3
+    if (dots < 2)
+      dots = 2
+    dots = ' ' + repeat(dots, '.') + ' '
     if (fails.length)
       num = Base.color('fail', num)
     else if (pass === total)
@@ -396,7 +400,7 @@ function Classic (runner) {
 }
 
 function indent (str, n) {
-  var ind = new Array(n + 1).join(' ')
+  var ind = repeat(n, ' ')
   str = ind + str.split('\n').join('\n' + ind)
   return str.replace(/(\n\s*)+$/, '\n')
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap-mocha-reporter.git



More information about the Pkg-javascript-commits mailing list