update-generated-text

1.0.1 • Public • Published

Update Generated Text

Update or append a block of generated text.

Append Example

import updateGeneratedText from 'update-generated-text'

const startString = '# _Start_Generated_Text'
const endString = '# _End_Generated_Text'

const newContents = '
coverage
.tmp
'

const text = `
# Gitignore
./.DS_Store
`

const newText = updateGeneratedText(
  startString,
  endString,
  newContents,
  text
)

/*
  # Gitignore
  ./.DS_Store

  # _Start_Generated_Text
  coverage
  .tmp
  # _End_Generated_Text
*/
console.log(newText)

Replace Example

import updateGeneratedText from 'update-generated-text'

const startString = '# _Start_Generated_Text'
const endString = '# _End_Generated_Text'

const newContents = '
coverage
.tmp
'

const text = `
# Gitignore

# _Start_Generated_Text
lib
# _End_Generated_Text

./.DS_Store
`

const newText = updateGeneratedText(
  startString,
  endString,
  newContents,
  text
)

/*
  # Gitignore

  # _Start_Generated_Text
  coverage
  .tmp
  # _End_Generated_Text

  ./.DS_Store
*/
console.log(newText)

Readme

Keywords

none

Package Sidebar

Install

npm i update-generated-text

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

1.99 kB

Total Files

3

Last publish

Collaborators

  • sartaj