From 8fbcf71da7553488ca6ca3b347da45853ace09cb Mon Sep 17 00:00:00 2001 From: Nik Graf Date: Mon, 26 Jun 2017 15:05:58 +0200 Subject: [PATCH] make sure to follow the serverless framework conventions for error handling --- lib/plugins/platform/platform.js | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/plugins/platform/platform.js b/lib/plugins/platform/platform.js index c806aab05..b2b225aae 100644 --- a/lib/plugins/platform/platform.js +++ b/lib/plugins/platform/platform.js @@ -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); + }); + }); }) ); }