Skip to content

Commit

Permalink
Merge pull request #82 from HyperBrain/set-alias-env-var-during-build
Browse files Browse the repository at this point in the history
Set SERVERLESS_ALIAS during build
  • Loading branch information
HyperBrain authored Nov 22, 2017
2 parents 2b9a0b5 + 8ea1a0e commit 05fa61a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = {
// Make alias available as ${self:provider.alias}
this._serverless.service.provider.alias = this._alias;

// Set SERVERLESS_ALIAS environment variable to let other plugins access it during the build
process.env.SERVERLESS_ALIAS = this._alias;

// Parse and check plugin options
if (this._options['alias-resources']) {
this._aliasResources = true;
Expand Down
5 changes: 5 additions & 0 deletions test/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ describe('#validate()', () => {
]));
});

it('should set SERVERLESS_ALIAS', () => {
return expect(awsAlias.validate()).to.eventually.be.fulfilled
.then(() => expect(process.env.SERVERLESS_ALIAS).to.equal('myStage'));
});

it('should succeed', () => {
return expect(awsAlias.validate()).to.eventually.be.fulfilled;
});
Expand Down

0 comments on commit 05fa61a

Please sign in to comment.