replace-in-file
Advanced tools
Comparing version 3.4.2 to 3.4.3
{ | ||
"name": "replace-in-file", | ||
"version": "3.4.2", | ||
"version": "3.4.3", | ||
"description": "A simple utility to quickly replace text in one or more files.", | ||
@@ -36,3 +36,3 @@ "homepage": "https://github.com/adamreisnz/replace-in-file#readme", | ||
"glob": "^7.1.2", | ||
"yargs": "^12.0.1" | ||
"yargs": "^12.0.5" | ||
}, | ||
@@ -39,0 +39,0 @@ "devDependencies": { |
@@ -25,2 +25,3 @@ # Replace in file | ||
- [Multiple values with the same replacement](#multiple-values-with-the-same-replacement) | ||
- [Custom regular expressions](#custom-regular-expressions) | ||
- [Multiple values with different replacements](#multiple-values-with-different-replacements) | ||
@@ -197,2 +198,15 @@ - [Using callbacks for `from`](#using-callbacks-for-from) | ||
### Custom regular expressions | ||
Use the [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) constructor to create any regular expression. | ||
```js | ||
const str = 'foo'; | ||
const regex = new RegExp('^' + str + 'bar', 'i'); | ||
const options = { | ||
from: regex, | ||
to: 'bar', | ||
}; | ||
``` | ||
### Using callbacks for `from` | ||
@@ -199,0 +213,0 @@ You can also specify a callback that returns a string or a regular expression. The callback receives the name of the file in which the replacement is being performed, thereby allowing the user to tailor the search string. The following example uses a callback to produce a search string dependent on the filename: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137105
350
Updatedyargs@^12.0.5