
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
grunt-regex-replace
Advanced tools
Grunt plugin to search and replace text content of files based on regular expression patterns
Grunt plugin to search and replace text content of files based on regular expression patterns
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-regex-replace
Then add this line to your project's grunt.js gruntfile:
grunt.loadNpmTasks('grunt-regex-replace');
Here is an sample of the definition within the object passed to grunt.initConfig ###Sample Code
regex-replace: {
src: ['foo/bar.js'],
actions: [
{
search: '(^|\\s)console.log',
replace: '//console.log',
flags: 'g'
},{
search: 'var v = \'[^\']*\';',
replace: 'var v = \'<%= pkg.release.version_code %>\';',
flags: ''
}
]
}
Takes the path to the files relative to the grunt file, it accepts strings as well as an array of file paths. Also supports templates, e.g
src: 'customisation/*.js',
src: ['foo/bar.js','foo/foo.js'],
src: ['<%= pkg.id %>/bar.js', 'foo/foo.js'],
###actions property Accepts an array of objects defining the actions to take place. Each action contains a search property, a replace property and a flags property. An example af an object.
{
search:'(^|\\s)console.log',
replace:'//console.log',
flags:'gi'
}
###search property A regular expression string defining the text contet to be found. ###replace property A string/ regular expression pattern to replace the text content. ###flags property Regular expressions options (ie gmi). if the flags property is not defined it defaults to 'g'. To specify no options, set the flags to empty string (ie flags : '').
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
(Nothing yet)
Grunt plugin to search and replace text content of files based on regular expression patterns
FAQs
Grunt plugin to search and replace text content of files based on regular expression patterns
The npm package grunt-regex-replace receives a total of 1,674 weekly downloads. As such, grunt-regex-replace popularity was classified as popular.
We found that grunt-regex-replace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.