replace-in-file
Advanced tools
Comparing version 2.6.3 to 2.6.4
{ | ||
"name": "replace-in-file", | ||
"version": "2.6.3", | ||
"version": "2.6.4", | ||
"description": "A simple utility to quickly replace text in one or more files.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/adamreisnz/replace-in-file#readme", |
@@ -76,2 +76,13 @@ # Replace in file | ||
### Using callbacks for `to` | ||
As the `to` parameter is passed straight to the native [String replace method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace), you can also specify a callback. The following example uses a callback to convert matching strings to lowercase: | ||
```js | ||
const options = { | ||
files: 'path/to/file', | ||
from: /SomePattern[A-Za-z-]+/g, | ||
to: (match) => match.toLowerCase(), | ||
}; | ||
``` | ||
### Asynchronous replacement with promises | ||
@@ -78,0 +89,0 @@ |
Sorry, the diff of this file is not supported yet
141828
166