@plurid/pipes.replacer

Content Replacer Pipe

Usage no npm install needed!

<script type="module">
  import pluridPipesReplacer from 'https://cdn.skypack.dev/@plurid/pipes.replacer';
</script>

README



License: DEL

plurid' pipes

Utility Pipes for Scripts

Content Replacer Pipe


Contents

Install

It is preferred to install the pipe globally

npm install -g @plurid/pipes.replacer

and run the script with the global NODE_PATH

export NODE_PATH=$(npm root --quiet -g) && node path/to/script.js

Usage

Require in script file, generate a replace function, use it on files.

const replacer = require('../distribution/index').default;


const main = async () => {
    // obtain a replacer function
    const replace = replacer(
        'searchString',
        'replaceString',
    );

    // use the replacer by passing paths to files
    await replace('/path/to/file');
}


main();

The following options can be passed to the replacer and to replace

export interface ReplacerOptions {
    /**
     * Regular Expression replacement flags.
     *
     * Default: `'gm'`.
     */
    flags: string;
}


export interface ReplaceOptions {
    /**
     * Return the replaced result.
     *
     * Default: `false`.
     */
    extract: boolean;

    /**
     * Write result to another file.
     */
    redirect: string;
}

Packages

Version

@plurid/pipes.finder • files finder pipe

Version

@plurid/pipes.replacer • content replacer pipe

Codeophon