33const  path  =  require ( 'path' ) 
44const  AWS  =  require ( 'aws-sdk' ) 
55const  notifyCFN  =  require ( 'dev-portal-common/notify-cfn' ) 
6+ const  {  inspectStringify }  =  require ( 'dev-portal-common/inspect-stringify' ) 
67const  fs  =  require ( 'fs' ) 
78const  klaw  =  require ( 'klaw' ) 
89// const crypto = require('crypto') 
@@ -67,9 +68,9 @@ async function cleanS3Bucket (bucketName) {
6768    Bucket : bucketName 
6869  } ) . promise ( ) 
6970
70-   console . log ( `result: ${ JSON . stringify ( result ,   null ,   4 ) }  ` ) 
71+   console . log ( `result: ${ inspectStringify ( result ) }  ` ) 
7172  const  keys  =  result . Contents . map ( ( obj )  =>  { 
72-     console . log ( `obj: ${ JSON . stringify ( obj ) }  ` ) 
73+     console . log ( `obj: ${ inspectStringify ( obj ) }  ` ) 
7374    return  {  Key : obj . Key  } 
7475  } ) 
7576
@@ -81,7 +82,7 @@ async function cleanS3Bucket (bucketName) {
8182        Objects : keys 
8283      } 
8384    } ) 
84-     console . log ( `deleteObjects result: ${ JSON . stringify ( result ,   null ,   4 ) }  ` ) 
85+     console . log ( `deleteObjects result: ${ inspectStringify ( result ) }  ` ) 
8586  } 
8687} 
8788
@@ -193,7 +194,7 @@ class State {
193194
194195    try  { 
195196      const  readResults  =  await  new  Promise ( ( resolve ,  reject )  =>  { 
196-         fs . readFile ( filePath ,  'utf-8' ,  ( err ,  data )  =>  { 
197+         fs . readFile ( filePath ,  null ,  ( err ,  data )  =>  { 
197198          if  ( err )  reject ( err ) 
198199          else  resolve ( data ) 
199200        } ) 
@@ -210,6 +211,13 @@ class State {
210211        params . ACL  =  'public-read' 
211212      } 
212213
214+       // body just pollutes logs and takes up space 
215+       console . log ( 'uploading to s3' ,  { 
216+         Bucket : params . Bucket , 
217+         Key : params . Key , 
218+         BodyLength : params . Body . byteLength , 
219+         ContentType : params . ContentType 
220+       } ) 
213221      uploadPromises . push ( s3 . upload ( params ,  options ) . promise ( ) ) 
214222    }  catch  ( error )  { 
215223      console . log ( 'Failed to upload:' ,  error ) 
@@ -262,6 +270,7 @@ class State {
262270            console . log ( 'pushing b/c Create' ,  data . path ) 
263271          }  else  if  ( this . event . ResourceProperties . RebuildMode  ===  'overwrite-content' )  { 
264272            // always write everything on an overwrite 
273+             console . log ( 'pushing b/c RebuildMode=overwrite-content' ,  data . path ) 
265274          }  else  if  ( ! / b u i l d \/ c u s t o m - c o n t e n t / . test ( data . path ) )  { 
266275            // only write non custom-content files on everything else 
267276            console . log ( 'pushing b/c not custom' ,  data . path ) 
0 commit comments