From 43f0288c6ca8382dac266f8b09a60b57d0e6837b Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 8 Jun 2015 12:31:17 -0400 Subject: [PATCH] Check that the passed application exists before asking to choose device --- build/actions/device.js | 5 +++++ lib/actions/device.coffee | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/build/actions/device.js b/build/actions/device.js index a46adc55..f8e449b2 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -188,6 +188,11 @@ return vcs.getApplicationName(process.cwd(), callback); }, function(applicationName, callback) { options.application = applicationName; + return resin.models.application.has(options.application, callback); + }, function(hasApplication, callback) { + if (!hasApplication) { + return callback(new Error("Invalid application: " + options.application)); + } if (params.device != null) { return callback(null, params.device); } diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index e97c4fda..42ec0d2f 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -265,6 +265,12 @@ exports.init = (applicationName, callback) -> options.application = applicationName + resin.models.application.has(options.application, callback) + + (hasApplication, callback) -> + if not hasApplication + return callback(new Error("Invalid application: #{options.application}")) + return callback(null, params.device) if params.device? visuals.patterns.selectDrive(callback)