Skip to content

Commit f354536

Browse files
committed
replace BbPromise with native Promise
1 parent acba8ca commit f354536

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

deploy/lib/setIamPolicy.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict';
22

3-
const BbPromise = require('bluebird');
43
const ServerlessError = require('serverless/lib/classes/Error').ServerlessError;
54

65
module.exports = {
76
setIamPolicy() {
8-
return BbPromise.bind(this).then(this.getFunctions).then(this.setPolicies);
7+
return Promise.resolve()
8+
.then(() => this.getFunctions())
9+
.then(() => this.setPolicies());
910
},
1011

1112
getFunctions() {
@@ -29,7 +30,7 @@ module.exports = {
2930
// If there are no IAM policies configured with any function, there is nothing to
3031
// do here.
3132
if (!policies || !Object.keys(policies).length) {
32-
return BbPromise.resolve();
33+
return Promise.resolve();
3334
}
3435
this.serverless.cli.log('Setting IAM policies...');
3536

@@ -67,6 +68,6 @@ module.exports = {
6768
}
6869
});
6970

70-
return BbPromise.all(promises);
71+
return Promise.all(promises);
7172
},
7273
};

deploy/lib/setIamPolicy.test.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const sinon = require('sinon');
4-
const BbPromise = require('bluebird');
54

65
const GoogleProvider = require('../../provider/googleProvider');
76
const GoogleDeploy = require('../googleDeploy');
@@ -39,8 +38,8 @@ describe('SetIamPolicy', () => {
3938
let setPoliciesStub;
4039

4140
beforeEach(() => {
42-
getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(BbPromise.resolve());
43-
setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(BbPromise.resolve());
41+
getFunctionsStub = sinon.stub(googleDeploy, 'getFunctions').returns(Promise.resolve());
42+
setPoliciesStub = sinon.stub(googleDeploy, 'setPolicies').returns(Promise.resolve());
4443
});
4544

4645
afterEach(() => {
@@ -58,7 +57,7 @@ describe('SetIamPolicy', () => {
5857

5958
describe('#getFunctions', () => {
6059
it('should return "undefined" if no functions are found', () => {
61-
requestStub.returns(BbPromise.resolve([]));
60+
requestStub.returns(Promise.resolve([]));
6261

6362
return googleDeploy.getFunctions().then((foundFunctions) => {
6463
expect(foundFunctions).toEqual(undefined);
@@ -81,7 +80,7 @@ describe('SetIamPolicy', () => {
8180
const response = {
8281
functions: [{ name: 'cloud-function-1' }, { name: 'cloud-function-2' }],
8382
};
84-
requestStub.returns(BbPromise.resolve(response));
83+
requestStub.returns(Promise.resolve(response));
8584

8685
return googleDeploy.getFunctions().then((foundFunctions) => {
8786
expect(foundFunctions).toEqual([
@@ -160,7 +159,7 @@ describe('SetIamPolicy', () => {
160159
googleDeploy.serverless.service.provider.functionIamBindings = {
161160
'cloud-function-2': [{ role: 'roles/cloudfunctions.invoker', members: ['allUsers'] }],
162161
};
163-
requestStub.returns(BbPromise.resolve());
162+
requestStub.returns(Promise.resolve());
164163

165164
return googleDeploy.setPolicies(foundFunctions).then(() => {
166165
expect(consoleLogStub.calledOnce).toEqual(true);

0 commit comments

Comments
 (0)