@@ -57,13 +57,17 @@ function getMaxLevel(options: Options = {}) {
5757}
5858
5959function getAgeSeconds ( options : Options = { } ) {
60- return options . age && options . age . seconds ? options . age . seconds : null ;
60+ if ( ! options . age ) {
61+ return null ;
62+ }
63+
64+ return options . age . seconds ?? null ;
6165}
6266
6367function doDeleteDirectory (
6468 currentDir : string ,
65- options : Options = { } ,
6669 currentLevel : number ,
70+ options : Options = { } ,
6771) {
6872 let doDelete = false ;
6973
@@ -106,7 +110,7 @@ function doDeleteFile(currentFile: string, options: Options = {}) {
106110 const extensions = options . extensions ? options . extensions : null ;
107111 const files = options . files ? options . files : null ;
108112 const prefix = options . prefix ? options . prefix : null ;
109- const ignore = options && options . ignore ? options . ignore : null ;
113+ const ignore = options . ignore ?? null ;
110114
111115 // return the last portion of a path, the filename aka basename
112116 const basename = path . basename ( currentFile ) ;
@@ -203,7 +207,7 @@ const findRemoveSync = function (
203207 // check directories before deleting files inside.
204208 // this to maintain the original creation time,
205209 // because linux modifies creation date of folders when files within have been deleted.
206- deleteDirectory = doDeleteDirectory ( currentDir , options , currentLevel ) ;
210+ deleteDirectory = doDeleteDirectory ( currentDir , currentLevel , options ) ;
207211 }
208212
209213 if ( maxLevel === - 1 || currentLevel < maxLevel ) {
@@ -228,7 +232,7 @@ const findRemoveSync = function (
228232 const result = findRemoveSync ( currentFile , options , currentLevel ) ;
229233
230234 // merge results
231- removed = Object . assign ( { } , removed , result ) ;
235+ removed = { ... removed , ... result } ;
232236
233237 if ( options . totalRemoved !== undefined ) {
234238 options . totalRemoved += Object . keys ( result ) . length ;
0 commit comments