infinitered / gluegun

A delightful toolkit for building TypeScript-powered command-line apps.
MIT License
2.95k stars 147 forks source link

Makes toolbox patch function able to receive multiple options #706

Closed LORDBABUINO closed 4 years ago

LORDBABUINO commented 4 years ago

This allows to make multiple changes in a file at once with only one file access using toolbox.patching.patch function. Example:

const updated = await toolbox.patching.patch(
  textFile,
    {
      delete: 'some words',
    },
    {
      replace: 'very amazing',
      insert: 'patched info',
    }
)
jamonholmgren commented 4 years ago

Thanks for your patience, @LORDBABUINO , I've been focusing on some other things lately. This patch looks amazing and I think it's very well done. I'd merge it now, but we should probably update the docs first. Would you mind doing that?

LORDBABUINO commented 4 years ago

Hi, I updated the docs and fixed some bugs on patch. The function was crashing when it receives an insert that is already present in the file.

infinitered-circleci commented 4 years ago

:tada: This PR is included in version 4.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

jamonholmgren commented 4 years ago

@LORDBABUINO Thank you so much! Released now. :)