Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replace-in-file

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replace-in-file - npm Package Compare versions

Comparing version 3.4.2 to 3.4.3

4

package.json
{
"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:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc