npm.io
2.0.2 • Published 1 week ago

@automattic/vip-search-replace

Licence
MIT
Version
2.0.2
Deps
1
Size
16 kB
Vulns
0
Weekly
0
Stars
5

nlm-github nlm-version

VIP Search & Replace

How to use this package?

const { replace } = require( '@automattic/vip-search-replace' );
const { pipeline } = require( 'node:stream/promises' );

// Create a readable and writeable stream. Can be any stream: File, std, etc...
const readableStream = fs.createReadStream( 'path_to_sql_file.sql' );
const writeableStream = fs.createWriteStream( 'path_to_sql_file_replaced.sql', { encoding: 'utf8' } );

const result = await replace( readableStream, [ 'thisdomain.com', 'thatdomain.com' ] );

await pipeline( result, writeableStream );

The returned stream can fail after producing output if the child process exits unsuccessfully. Handle errors from the stream or pipeline and discard any incomplete output.

Contributing

For details about contributing to this project (e.g. setting up development environment, publishing a release, etc.), please see CONTRIBUTING.md.