From f9979731fb5c90a8f724a36cea1c5c18557c116d Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 6 Mar 2016 17:53:11 +0100 Subject: [PATCH] Fix table formatting when there are multiple lines --- lib/generate/index.js | 30 ++++++++++++++++++++---------- lib/generate/index.test.js | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/generate/index.js b/lib/generate/index.js index 0b0311d..80c20b0 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -4,6 +4,14 @@ var _ = require('lodash/fp'); var formatBadge = require('./formatBadge'); var formatContributor = require('./formatContributor'); +function injectContentBetween(lines, content, startIndex, endIndex) { + return [].concat( + lines.slice(0, startIndex), + content, + lines.slice(endIndex) + ); +} + var injectBetweenTags = _.curry(function(tag, newContent, previousContent) { var lines = previousContent.split('\n'); var openingTagIndex = _.findIndex(_.startsWith('', '| Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! | Kent C. Dodds is awesome! |', - '| Kent C. Dodds is awesome! | Kent C. Dodds is awesome! |', '| :---: | :---: | :---: | :---: | :---: |', + '| Kent C. Dodds is awesome! | Kent C. Dodds is awesome! |', '', '', 'Thanks a lot guys!'