Skip to content

Commit 75fccfd

Browse files
authored
Merge pull request #43 from serverless/add-provider-based-stage-and-region-support
Add provider based stage and region support
2 parents 90d07d5 + 1d8785f commit 75fccfd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

shared/utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
'use strict';
22

3+
const _ = require('lodash');
34
const BbPromise = require('bluebird');
45

56
module.exports = {
67
setDefaults() {
7-
this.options.stage = this.options.stage
8+
this.options.stage = _.get(this, 'options.stage')
9+
|| _.get(this, 'serverless.service.provider.stage')
810
|| 'dev';
9-
this.options.region = this.options.region
11+
this.options.region = _.get(this, 'options.region')
12+
|| _.get(this, 'serverless.service.provider.region')
1013
|| 'us-central1';
1114

1215
return BbPromise.resolve();

shared/utils.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,17 @@ describe('Utils', () => {
3131
expect(googleCommand.options.region).toEqual('my-region');
3232
});
3333
});
34+
35+
it('should set the provider values for stage and region if provided', () => {
36+
googleCommand.serverless.service.provider = {
37+
stage: 'my-stage',
38+
region: 'my-region',
39+
};
40+
41+
return googleCommand.setDefaults().then(() => {
42+
expect(googleCommand.options.stage).toEqual('my-stage');
43+
expect(googleCommand.options.region).toEqual('my-region');
44+
});
45+
});
3446
});
3547
});

0 commit comments

Comments
 (0)