Check that the passed application exists before asking to choose device

This commit is contained in:
Juan Cruz Viotti 2015-06-08 12:31:17 -04:00
parent 47e6371e2e
commit 43f0288c6c
2 changed files with 11 additions and 0 deletions

View File

@ -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);
}

View File

@ -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)