In order to consistently return a promise from my function, I either return the promise from an api call, or generate a deferred object, then reject it, and return it's promise...
function listIssues(user, repository, filters) {
if (!user || !repository) {
// this seems a bit long winded, is there an easier way..?
var deferred = Q.defer();
var warning = helper.chalk.gray('You must specifiy user/organization and repository name...');
deferred.reject(warning);
return deferred.promise;
} else {
return api.getIssues(user, repository, filters);
}
}
Is there a shortcut to do all that in one step?