@plurid/pipes.replacer
v0.0.0-3
Published
Content Replacer Pipe
Downloads
7
Readme
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
@plurid/pipes.finder • files finder pipe
@plurid/pipes.replacer • content replacer pipe