Skip to content

Commit

Permalink
Fix crash with snapshot testing
Browse files Browse the repository at this point in the history
Seems like `String#repeat` does not like negative numbers.
  • Loading branch information
sindresorhus committed Feb 2, 2017
1 parent 34bebc4 commit c980f97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/code-excerpt.js
Expand Up @@ -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 || {};
Expand Down

0 comments on commit c980f97

Please sign in to comment.