Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ module.exports.list = async function (options, path) {
module.exports.download = async function (options, path, fileName) {
mkdirp(dirname(fileName));

// Check if file exists and skip if overwrite is not enabled
// eslint-disable-next-line security/detect-non-literal-fs-filename
if (fs.existsSync(fileName) && !options.overwrite) {
console.log(chalk.yellow(`Skipped (already exists): ${fileName}`));
return;
}

const response = await request(options).get(path);

const bar = progress(fileName);
Expand Down
5 changes: 5 additions & 0 deletions lib/cmds/files_cmds/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ exports.builder = yargs => {
alias: 'l',
type: 'number',
default: 1000
}).option('overwrite', {
describe: 'Overwrite existing files. By default, existing files are skipped.',
alias: 'f',
type: 'boolean',
default: false
});
};

Expand Down
Loading