From c980f978cd70969cfbe1114d8e1ef4f1eb39def3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 2 Feb 2017 22:42:13 +0700 Subject: [PATCH] Fix crash with snapshot testing Seems like `String#repeat` does not like negative numbers. --- lib/code-excerpt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/code-excerpt.js b/lib/code-excerpt.js index 76002a4b5..03f2e7d82 100644 --- a/lib/code-excerpt.js +++ b/lib/code-excerpt.js @@ -6,7 +6,7 @@ const truncate = require('cli-truncate'); const chalk = require('chalk'); const formatLineNumber = (lineNumber, maxLineNumber) => - ' '.repeat(String(maxLineNumber).length - String(lineNumber).length) + lineNumber; + ' '.repeat(Math.max(0, String(maxLineNumber).length - String(lineNumber).length)) + lineNumber; module.exports = (file, line, options) => { options = options || {};