File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,11 +52,12 @@ export const dump = async (dumpKey: string, _name?: string) => {
5252 await client . close ( )
5353 for ( const db of dbs . databases . map ( db => db . name ) . filter ( db => ! config . mongo . ignoreDBs . includes ( db ) ) ) {
5454 debug ( `work on db ${ db } ` )
55- debug ( `create tmp file ${ config . tmpdir } ` )
5655 const tmpFile = await tmp . file ( { dir : config . tmpdir } )
57- debug ( `created tmp file ${ tmpFile . path } ` )
5856 const tmpPath = tmpFile . path
59- let cmd = `mongodump --uri ${ config . mongo . url } /${ db } ?readPreference=${ config . mongo . readPreference } --gzip --archive=${ tmpPath } `
57+ const mongoUrl = new URL ( config . mongo . url )
58+ mongoUrl . searchParams . set ( 'readPreference' , config . mongo . readPreference )
59+ mongoUrl . pathname = '/' + db
60+ let cmd = `mongodump --uri ${ mongoUrl . href } --gzip --archive=${ tmpPath } `
6061 if ( config . mongo . dumpParams && config . mongo . dumpParams [ db ] ) {
6162 cmd += ` ${ config . mongo . dumpParams [ db ] } `
6263 }
Original file line number Diff line number Diff line change 11import { spawn , type SpawnOptions } from 'node:child_process'
2+ import debugModule from 'debug'
3+
4+ const debug = debugModule ( 'exec' )
25
36export async function exec ( cmd : string , opts : SpawnOptions = { } ) {
4- console . log ( 'exec' , cmd , opts )
7+ debug ( 'exec command ' , cmd , opts )
58 return new Promise < void > ( ( resolve , reject ) => {
69 const childProcess = spawn ( cmd , { shell : true , stdio : 'inherit' , ...opts } )
710 childProcess . on ( 'error' , reject )
You can’t perform that action at this time.
0 commit comments