Skip to content

Commit

Permalink
Merge pull request #43 from serverless/add-provider-based-stage-and-r…
Browse files Browse the repository at this point in the history
…egion-support

Add provider based stage and region support
  • Loading branch information
pmuens committed Mar 6, 2017
2 parents 90d07d5 + 1d8785f commit 75fccfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shared/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use strict';

const _ = require('lodash');
const BbPromise = require('bluebird');

module.exports = {
setDefaults() {
this.options.stage = this.options.stage
this.options.stage = _.get(this, 'options.stage')
|| _.get(this, 'serverless.service.provider.stage')
|| 'dev';
this.options.region = this.options.region
this.options.region = _.get(this, 'options.region')
|| _.get(this, 'serverless.service.provider.region')
|| 'us-central1';

return BbPromise.resolve();
Expand Down
12 changes: 12 additions & 0 deletions shared/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ describe('Utils', () => {
expect(googleCommand.options.region).toEqual('my-region');
});
});

it('should set the provider values for stage and region if provided', () => {
googleCommand.serverless.service.provider = {
stage: 'my-stage',
region: 'my-region',
};

return googleCommand.setDefaults().then(() => {
expect(googleCommand.options.stage).toEqual('my-stage');
expect(googleCommand.options.region).toEqual('my-region');
});
});
});
});

0 comments on commit 75fccfd

Please sign in to comment.