@@ -38,7 +38,6 @@ const spawnAsync = (cmd) => new Promise((resolve) => {
3838 * @returns {Promise<{ cmd: string[], stdout: string, stderr: string, status: number | null, signal: NodeJS.Signals | null, error?: Error}> }
3939 */
4040const dryRunSuccess = ( cmd ) => new Promise ( ( resolve ) => {
41- console . log ( 'Starting ' + cmd . join ( ' ' ) ) ;
4241 setTimeout ( ( ) => resolve ( { cmd, stdout : '' , stderr : '' , status : 0 , signal : null } ) , Math . floor ( Math . random ( ) * 100 ) ) ;
4342} ) ;
4443
@@ -260,38 +259,19 @@ const makeRedirectObjects = async (dryRun, bucket, prefix, parallel, redirects)
260259 const tasks = parallelGenerator ( parallel , generateRedirectObjectsAsync ( dryRun , bucket , prefix , redirectsByLocation ) ) ;
261260 let processedCount = 0 ;
262261 for await ( const taskResult of tasks ) {
263- const { subPath, cmd, error } = taskResult ;
262+ const { subPath, cmd, error, copied } = taskResult ;
264263 processedCount ++ ;
264+ console . log ( `Processed ${ ( ( processedCount / redirectsByLocation . size ) * 100 ) . toFixed ( 1 ) } %: ${ taskResult . subPath } ` ) ;
265265 if ( error ) {
266266 errorCount ++ ;
267+ console . error ( `\nCommand: ${ cmd . join ( ' ' ) } ` ) ;
268+ console . error ( `Error ${ copied ? 'Updating' : 'Creating' } S3 object ${ prefix } /${ subPath } :` , error ) ;
269+ console . error ( '' ) ;
267270 } else {
268271 successCount ++ ;
269272 }
270- console . log ( `\nProcessed ${ processedCount } of ${ redirectsByLocation . size } : ${ taskResult . subPath } ` ) ;
271- const fullPath = `${ prefix } /${ subPath } ` ;
272- if ( taskResult . copied ) {
273- console . log ( `Updating S3 object: ${ fullPath } ` ) ;
274- console . log ( `Command: ${ cmd . join ( ' ' ) } ` ) ;
275- if ( taskResult . error ) {
276- console . error ( `Error copying S3 object ${ fullPath } :` , error ) ;
277- } else {
278- console . log ( `Successfully updated S3 object ${ fullPath } ` ) ;
279- }
280- } else {
281- console . log ( `Created new S3 object: ${ fullPath } ` ) ;
282- console . log ( `Command: ${ cmd . join ( ' ' ) } ` ) ;
283- if ( taskResult . error ) {
284- console . error ( `Error creating S3 object ${ fullPath } :` , error ) ;
285- } else {
286- console . log ( `Successfully created S3 object ${ fullPath } ` ) ;
287- }
288- }
289273 }
290-
291- console . log ( `\nSummary:` ) ;
292- console . log ( `Successfully processed: ${ successCount } objects` ) ;
293- console . log ( `Errors: ${ errorCount } objects` ) ;
294- console . log ( 'Redirect object generation completed.' ) ;
274+ console . log ( `\nFinished with ${ errorCount } error(s)` ) ;
295275} ;
296276
297277const usage = ( ) => `
0 commit comments