-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support more replace-in-file functionality (#172)
* docs: generate documentation for current HEAD The documentation was not completely up-to-date with the state of the code. The URLs now all point back to the main repository. * test: fix "file contents contain" assertion This previously only set up a matcher and did not actually assert anything. This can be verified by changing to `expect.not.stringContaining` and seeing whether any tests start to fail. * feat: support full `from` functionality of `replace-in-file` To better support configuration through JSON, the default behavior of `from` for string inputs was previously changed relative to that of the `replace-in-file` package. For more advanced use cases, i.e. where a JavaScript configuration file is used, the full functionality of the `replace-in-file` package is made available. * fix: improve typing for multi-argument callback functions for `to` The `to` callback function can be as simple as a two-argument function receiving the matched string and the filename it was matched in. However if `from` is a regular expression, the function arguments may additionally contain captures, the offset for the matched substring, the whole string being inspected, etc. This type definition ensures those functions are accepted, but require providing additional type information. * feat: pass the `semantic-release` `Context` to `from` callback functions Information from the `semantic-release` `Context` may be useful when determining the which content should be replaced. The `Context` is made available as the last argument to the callback function. Alternative implementation of #167. * feat: pass the `semantic-release` `Context` to `to` callback functions Information from the `semantic-release` `Context` may be useful when determining the replacement text. The `Context` is made available as the last argument to the callback function. Alternative implementation of #167. * feat: accept multiple `from` matchers The underlying `replace-in-file` package accepts multiple matchers to be passed as an array. This functionality is made available for multiple basic string and more advanced replacements. * feat: accept multiple `to` replacements The underlying `replace-in-file` package accepts multiple replacements to be passed as an array. This functionality is made available for multiple basic string replacements and callback functions. When using multiple replacements the number of replacements needs to be the same as the number of matchers. Otherwise only a subset of the replacements is used, e.g. it's not possible to use a single string matcher and provide multiple replacements.
- Loading branch information
Showing
7 changed files
with
358 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.