Socket
Socket
Sign inDemoInstall

replace-in-file

Package Overview
Dependencies
Maintainers
0
Versions
79
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 8.0.1 to 8.0.2

.yarn/install-state.gz

2

bin/cli.js

@@ -36,3 +36,3 @@ #!/usr/bin/env node

//If the isRegex flag is passed, convert the from parameter to a RegExp object
if (isRegex) {
if (isRegex && typeof from === 'string') {
const flags = from.replace(/.*\/([gimyus]*)$/, '$1')

@@ -39,0 +39,0 @@ const pattern = from.replace(new RegExp(`^/(.*?)/${flags}$`), '$1')

{
"name": "replace-in-file",
"type": "module",
"version": "8.0.1",
"version": "8.0.2",
"description": "A simple utility to quickly replace text in one or more files.",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/adamreisnz/replace-in-file#readme",

@@ -522,2 +522,4 @@ # Replace in file

It is not necessary to use the `--isRegex` flag in this case.
## A note on using globs with the CLI

@@ -524,0 +526,0 @@ When using the CLI, the glob pattern is handled by the operating system. But if you specify the glob pattern in the configuration file, the package will use the glob module from the Node modules, and this can lead to different behaviour despite using the same pattern.

@@ -20,3 +20,3 @@ import path from 'node:path'

//Since we can't store Regexp in JSON, convert from string if needed
if (config.from && config.from.startsWith('/')) {
if (config.from && config.from.match(/.*\/([gimyus]*)$/)) {
config.from = new RegExp(config.from)

@@ -23,0 +23,0 @@ }

@@ -73,3 +73,3 @@ import {expect, use, should} from 'chai'

files: ['file.txt'],
from: 'foo',
from: '/foo',
to: 'bar',

@@ -87,2 +87,21 @@ }

})
it('should ignore the isRegex flag if a regex has already been provided', async () => {
//Test config
const config = {
files: ['file.txt'],
from: '/foo/g',
to: 'bar',
isRegex: true,
}
fs.writeFileSync('config.json', JSON.stringify(config), 'utf8')
//Load config
const cfg = await loadConfig('config.json')
expect(cfg.from).to.be.an.instanceof(RegExp)
//Clean up
fs.unlinkSync('config.json')
})
})

@@ -89,0 +108,0 @@

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