File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ module.exports.list = async function (options, path) {
103103module . exports . download = async function ( options , path , fileName ) {
104104 mkdirp ( dirname ( fileName ) ) ;
105105
106+ // Check if file exists and skip if overwrite is not enabled
107+ // eslint-disable-next-line security/detect-non-literal-fs-filename
108+ if ( fs . existsSync ( fileName ) && ! options . overwrite ) {
109+ console . log ( chalk . yellow ( `Skipped (already exists): ${ fileName } ` ) ) ;
110+ return ;
111+ }
112+
106113 const response = await request ( options ) . get ( path ) ;
107114
108115 const bar = progress ( fileName ) ;
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ exports.builder = yargs => {
2424 alias : 'l' ,
2525 type : 'number' ,
2626 default : 1000
27+ } ) . option ( 'overwrite' , {
28+ describe : 'Overwrite existing files. By default, existing files are skipped.' ,
29+ alias : 'f' ,
30+ type : 'boolean' ,
31+ default : false
2732 } ) ;
2833} ;
2934
You can’t perform that action at this time.
0 commit comments