module.exports = (contents, anchor, line, file) => { if (contents.includes(line)) return contents const match = contents.match(anchor) if (match === null) throw new Error(`no ${anchor} in ${file} to insert "${line.trim()}" after`) const end = match.index + match[0].length return contents.slice(0, end) + "\n" + line + contents.slice(end) }