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.