Merge pull request #66 from resin-io/feature/device-init-has-app

Check that the passed application exists before asking to choose device
This commit is contained in:
Juan Cruz Viotti 2015-06-09 08:28:10 -04:00
commit 6d8fd6e547
2 changed files with 11 additions and 0 deletions

View File

@ -188,6 +188,11 @@
return vcs.getApplicationName(process.cwd(), callback); return vcs.getApplicationName(process.cwd(), callback);
}, function(applicationName, callback) { }, function(applicationName, callback) {
options.application = applicationName; 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) { if (params.device != null) {
return callback(null, params.device); return callback(null, params.device);
} }

View File

@ -265,6 +265,12 @@ exports.init =
(applicationName, callback) -> (applicationName, callback) ->
options.application = applicationName 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? return callback(null, params.device) if params.device?
visuals.patterns.selectDrive(callback) visuals.patterns.selectDrive(callback)