
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
karma-regex-preprocessor
Advanced tools
Regular expression replace preprocessor for karma test runner
A karma preprocessor which does one or more regular expression substitutions on the file contents. It effectively just calls String.prototype.replace() with the parameters specified in the configuration.
Historically, the main motivation for this was that https://github.com/mode needed something to quickly simulate the nginx HttpSubModule.
Install from npm:
npm install karma-regex-preprocessor --save-dev
Example configuration:
// karma.conf.js
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.js': ['regex']
},
regexPreprocessor: {
rules: [
{
// Replacements for File1.
fileName: "File1.js", replacement: [
// Simple string replace of 'foo' with 'bar'.
{ replace: "foo", with: "bar" },
// Prefix all numbers with '-'.
{ replace: /[\d]+/g, with: "-$1" },
// Use a function to calculate replacement.
{ replace: "%rand%", with: function (match) { return Math.random() } }
]
},
{
// Replacements for File2.
fileName: "File2.js", replacement: [
// Simple string replace of 'foo' with 'baz'.
{ replace: "foo", with: "baz" },
// Prefix all numbers with '€'.
{ replace: /[\d]+/g, with: "€$1" },
// Use a function to calculate replacement.
{ replace: "%rand%", with: function (match) { return Math.random()*5 } }
]
}
]
}
});
};
The MIT License (MIT)
FAQs
Regular expression replace preprocessor for karma test runner
We found that karma-regex-preprocessor 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.