New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seek-and-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

seek-and-replace

Find and replace string occurrences in directories, files and fileContent.

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Seek and Replace

Find and replace string occurrences in directories, files and fileContent.

Build Status

Usage

Instance

We create a SeekAndReplace instance by providing two paramters:

  • replacePath: the where replacement should start
  • keyDefinitions: which are { key, replacement } objects defining what key to search for and with which value to replace it with
const namespace = 'OLLIE';
const replacePath = './src';

const keyDefinitions = [
    {
        key: 'NAME',
        replacement: 'naampie',
    }, {
        key: 'AUTHOR',
        replacement: 'Jimmy',
    },
];

const replacer = new SeekAndReplace(namespace, replacePath, keyDefinitions);

instance.replace()

A SeekAndReplace instance has 1 key functionality: replace! When calling instance.replace() all directories, files and file contents starting at the replacePath will be scanned and replaced with all key definitions.

SeekAndReplace.smartReplace()

SeekAndReplace exposes a static method smartReplace which is used by the SeekAndReplace instance but can also be used outside separately.

SeekAndReplace.smartReplace(namespace, string, key, replacement)

Smart replace transformations

Key definitions can have smart transformations applied to it. The format is _OLLIE_NAME_TRANSFORMATION_.

The following transformations are supported:

DefinitionExample
nonePoint of Sale
_AS_DOMAIN_pointofsale
_WITHOUT_SPACES_PointofSale
_LOWER_CASE_point of sale
_UPPER_CASE_POINT OF SALE
_SNAKE_CASE_point_of_sale
_CAMEL_CASE_pointOfSale
_KEBAB_CASE_point-of-sale
_START_CASE_Point Of Sale

Keywords

FAQs

Package last updated on 13 Feb 2017

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