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

search-act-replace

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-act-replace

Search through file system and replace after callback.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Search-Act-Replace

Install with npm install search-act-replace.

This modules takes a root path, a regex and a callback. It will recursively search the file within the root path and call the callback for each match. It also provides another callback, which you can feed with the text that the match should be replaced with (or false for no replacement).

Let the example talk for itself.

Example

var sar = require('search-act-replace');

sar('./test', /www\.\w+\.com/g, function (match, file, replace) {
  http.get('http://' + match[0], function (res) {
    if (res.statusCode !== 200) {
      replace(match[0] + ' (link broken)');
    } else {
      replace(false);
    }
  });
});

The script will automatically ignore .git, .svn, node_modules, and bower_components folders (have a look at the .sarignore file) as well as files specified in the roots .gitignore file as well as a custom .sarignore file in the root folder.

FAQs

Package last updated on 19 May 2014

Did you know?

Socket

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.

Install

Related posts

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