Skip to content

Find & replace dirs, files and file contents, including a touch of magic.

Notifications You must be signed in to change notification settings

hoetmaaiers/seek-and-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 options = {
    ignorePaths: ['node_modules', '.idea', '.env*']
}

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

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:

Definition Example
none Point 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

About

Find & replace dirs, files and file contents, including a touch of magic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published