Skip to content

Commit

Permalink
adjust code excerpt line trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes committed Jan 30, 2017
1 parent 2fa8da9 commit 9e9642f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/code-excerpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (file, line, options) => {

const lines = excerpt.map(item => ({
line: item.line,
value: truncate(item.value, maxWidth - String(line).length - 1)
value: truncate(item.value, maxWidth - String(line).length - 5)
}));

const joinedLines = lines.map(line => line.value).join('\n');
Expand Down
6 changes: 3 additions & 3 deletions test/code-excerpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ test('truncate lines', t => {

const excerpt = codeExcerpt(path, 2, {maxWidth: 14});
const expected = [
` ${chalk.grey('1:')} function a(…`,
chalk.bgRed(` 2: alert(); `),
` ${chalk.grey('3:')} } `
` ${chalk.grey('1:')} functio…`,
chalk.bgRed(` 2: alert`),
` ${chalk.grey('3:')} } `
].join('\n');

t.is(excerpt, expected);
Expand Down

0 comments on commit 9e9642f

Please sign in to comment.