feat(cli): new --dry-run option to skip resizing the files / creating the website

The index is still updated, and the media folder is still scanned to log how many tasks are required.
This is useful to know what thumbsup is about to do, without actually running the expensive tasks.
pull/93/head
Romain 7 years ago
parent e5f6df3d28
commit cd3d699b34

@ -158,6 +158,12 @@ const OPTIONS = {
'default': true
},
'dry-run': {
description: "Update the index, but don't create the media files / website",
type: 'boolean',
'default': false
},
// ------------------------------------
// Deprecated options
// ------------------------------------
@ -235,7 +241,8 @@ exports.get = (args) => {
footer: opts['footer'],
albumsOutputFolder: opts['albums-output-folder'],
usageStats: opts['usage-stats'],
log: opts['log']
log: opts['log'],
dryRun: opts['dry-run']
}
}

@ -23,18 +23,26 @@ exports.build = function (opts, done) {
{
title: 'Resizing media',
task: (ctx, task) => {
return steps.process(ctx.files, opts, task)
const tasks = steps.process(ctx.files, opts, task)
if (!opts.dryRun) {
return tasks
} else {
task.skip()
return null
}
}
},
{
title: 'Cleaning up',
enabled: (ctx) => opts.cleanup,
skip: () => opts.dryRun,
task: (ctx) => {
return steps.cleanup(ctx.files, opts.output)
}
},
{
title: 'Creating website',
skip: () => opts.dryRun,
task: (ctx) => new Promise((resolve, reject) => {
website.build(ctx.album, opts, err => {
err ? reject(err) : resolve()

Loading…
Cancel
Save