Giter Club home page Giter Club logo

seek-and-replace's Introduction

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

seek-and-replace's People

Contributors

hoetmaaiers avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.