From f3545366200904085aed3ea59bf3413736ed2665 Mon Sep 17 00:00:00 2001 From: Erick Daniszewski Date: Wed, 12 May 2021 08:43:58 -0400 Subject: [PATCH] replace BbPromise with native Promise --- deploy/lib/setIamPolicy.js | 9 +++++---- deploy/lib/setIamPolicy.test.js | 11 +++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/deploy/lib/setIamPolicy.js b/deploy/lib/setIamPolicy.js index d2bf7cc..2443902 100644 --- a/deploy/lib/setIamPolicy.js +++ b/deploy/lib/setIamPolicy.js @@ -1,11 +1,12 @@ 'use strict'; -const BbPromise = require('bluebird'); const ServerlessError = require('serverless/lib/classes/Error').ServerlessError; module.exports = { setIamPolicy() { - return BbPromise.bind(this).then(this.getFunctions).then(this.setPolicies); + return Promise.resolve() + .then(() => this.getFunctions()) + .then(() => this.setPolicies()); }, getFunctions() { @@ -29,7 +30,7 @@ module.exports = { // If there are no IAM policies configured with any function, there is nothing to // do here. if (!policies || !Object.keys(policies).length) { - return BbPromise.resolve(); + return Promise.resolve(); } this.serverless.cli.log('Setting IAM policies...'); @@ -67,6 +68,6 @@ module.exports = { } }); - return BbPromise.all(promises); + return Promise.all(promises); }, }; diff --git a/deploy/lib/setIamPolicy.test.js b/deploy/lib/setIamPolicy.test.js index d8e6d96..cef4a87 100644 --- a/deploy/lib/setIamPolicy.test.js +++ b/deploy/lib/setIamPolicy.test.js @@ -1,7 +1,6 @@ 'use strict'; const sinon = require('sinon'); -const BbPromise = require('bluebird'); const GoogleProvider = require('../../provider/googleProvider'); const GoogleDeploy = require('../googleDeploy'); @@ -39,8 +38,8 @@ describe('SetIamPolicy', () => { let setPoliciesStub; beforeEach(() => { - getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(BbPromise.resolve()); - setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(BbPromise.resolve()); + getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(Promise.resolve()); + setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(Promise.resolve()); }); afterEach(() => { @@ -58,7 +57,7 @@ describe('SetIamPolicy', () => { describe('#getFunctions', () => { it('should return "undefined" if no functions are found', () => { - requestStub.returns(BbPromise.resolve([])); + requestStub.returns(Promise.resolve([])); return googleDeploy.getFunctions().then((foundFunctions) => { expect(foundFunctions).toEqual(undefined); @@ -81,7 +80,7 @@ describe('SetIamPolicy', () => { const response = { functions: [{ name: 'cloud-function-1' }, { name: 'cloud-function-2' }], }; - requestStub.returns(BbPromise.resolve(response)); + requestStub.returns(Promise.resolve(response)); return googleDeploy.getFunctions().then((foundFunctions) => { expect(foundFunctions).toEqual([ @@ -160,7 +159,7 @@ describe('SetIamPolicy', () => { googleDeploy.serverless.service.provider.functionIamBindings = { 'cloud-function-2': [{ role: 'roles/cloudfunctions.invoker', members: ['allUsers'] }], }; - requestStub.returns(BbPromise.resolve()); + requestStub.returns(Promise.resolve()); return googleDeploy.setPolicies(foundFunctions).then(() => { expect(consoleLogStub.calledOnce).toEqual(true);