make sure to follow the serverless framework conventions for error handling

This commit is contained in:
Nik Graf 2017-06-26 15:05:58 +02:00
parent a76ae91488
commit 8fbcf71da7
No known key found for this signature in database
GPG Key ID: 7A97512F916175F1

View File

@ -158,22 +158,25 @@ class Platform {
const readmePath = path.join(this.serverless.config.servicePath, 'README.md');
const serviceDataWithReadme = addReadme(serviceData, readmePath);
return this.publishServiceRequest(serviceDataWithReadme, clientWithAuth)
.then(() => {
const username = jwtDecode(authToken).nickname;
const serviceName = this.serverless.service.service;
const url = `${config.PLATFORM_FRONTEND_BASE_URL}services/${username}/${serviceName}`;
this.serverless
.cli.log('Service successfully published! Your service details are available at:');
this.serverless
.cli.log(chalk.green(url));
})
.catch(error => {
this.serverless.cli.log(
"Couldn't publish this deploy information to the Serverless Platform due: \n",
error
);
});
return new BbPromise((resolve, reject) => {
this.publishServiceRequest(serviceDataWithReadme, clientWithAuth)
.then(() => {
const username = jwtDecode(authToken).nickname;
const serviceName = this.serverless.service.service;
const url = `${config.PLATFORM_FRONTEND_BASE_URL}services/${username}/${serviceName}`;
this.serverless.cli.log(
'Service successfully published! Your service details are available at:'
);
this.serverless.cli.log(chalk.green(url));
resolve();
})
.catch(error => {
this.serverless.cli.log(
"Couldn't publish this deploy information to the Serverless Platform."
);
reject(error);
});
});
})
);
}