Check that an application exists before asking it's type. Closes #30

This commit is contained in:
Juan Cruz Viotti 2015-04-28 09:18:21 -04:00
parent 3d1f023ef5
commit 193cedae26
3 changed files with 12 additions and 1 deletions

View File

@ -31,6 +31,11 @@
action: function(params, options, done) {
return async.waterfall([
function(callback) {
return resin.models.application.has(params.name, callback);
}, function(hasApplication, callback) {
if (hasApplication) {
return callback(new Error('You already have an application with that name!'));
}
if (options.type != null) {
return callback(null, options.type);
}

View File

@ -37,6 +37,12 @@ exports.create =
async.waterfall([
(callback) ->
resin.models.application.has(params.name, callback)
(hasApplication, callback) ->
if hasApplication
return callback(new Error('You already have an application with that name!'))
return callback(null, options.type) if options.type?
resin.models.device.getSupportedDeviceTypes (error, deviceTypes) ->

View File

@ -63,7 +63,7 @@
"president": "^1.0.0",
"progress-stream": "^0.5.0",
"resin-cli-visuals": "^0.1.0",
"resin-sdk": "^1.3.1",
"resin-sdk": "^1.3.2",
"resin-settings-client": "^1.0.0",
"resin-vcs": "^1.2.0",
"tmp": "^0.0.25",