(oldContents, index, content)
| 26 | } |
| 27 | |
| 28 | const insertAtLineAtIndex = (oldContents, index, content) => { |
| 29 | const line = getLineNumberOfIndex(oldContents, index) |
| 30 | const lines = oldContents.split('\n') |
| 31 | lines.splice(line, 0, content) |
| 32 | |
| 33 | return `${lines |
| 34 | .join('\n') |
| 35 | .replace(/\n{3,}/g, '\n\n') |
| 36 | .replace(/\n*$/, '')}` |
| 37 | } |
| 38 | |
| 39 | export { insertAtLineAtIndex } |
no test coverage detected