 Promise = require('bluebird')
 once = require('lodash/once')
 isEmpty = require('lodash/isEmpty')
-size = require('lodash/size')
 errors = require('balena-errors')
 
 {

		.tap (applications) ->
			if isEmpty(applications)
				throw new errors.BalenaApplicationNotFound("#{owner}/#{appName}")
			if size(applications) > 1
				throw new errors.BalenaAmbiguousApplication("#{owner}/#{appName}")
		.get(0)
		.tap(normalizeApplication)

					if isEmpty(applications)
						throw new errors.BalenaApplicationNotFound(nameOrSlugOrId)

					if applications.length > 1
						throw new errors.BalenaAmbiguousApplication(nameOrSlugOrId)
				.get(0)
		.tap(normalizeApplication)
