From e815d97265f8973f239ead2656cb465d356cc668 Mon Sep 17 00:00:00 2001 From: Josh Leeb-du Toit Date: Tue, 14 Nov 2017 22:02:43 +1100 Subject: [PATCH] fix(CLI): add check for drive flag with yes flag (#1753) Add an options check for the `drive` flag to appear with the `yes` flag. If the `yes` flag appears without the `drive` flag then a user error will be thrown. Change-Type: patch Link: https://github.com/resin-io/etcher/pull/1753 Fixes: https://github.com/resin-io/etcher/issues/1454 --- lib/cli/options.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/cli/options.js b/lib/cli/options.js index 049c35b0..0dda5b84 100644 --- a/lib/cli/options.js +++ b/lib/cli/options.js @@ -134,6 +134,18 @@ module.exports = yargs return true }) + // Assert that if the `yes` flag is provided, the `drive` flag is also provided. + .check((argv) => { + if (argv.yes && !argv.drive) { + throw errors.createUserError({ + title: 'Missing drive', + description: 'You need to explicitly pass a drive when disabling interactively' + }) + } + + return true + }) + .options({ help: { describe: 'show help',