Skip to content

Commit 05fa61a

Browse files
authored
Merge pull request #82 from HyperBrain/set-alias-env-var-during-build
Set SERVERLESS_ALIAS during build
2 parents 2b9a0b5 + 8ea1a0e commit 05fa61a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/validate.js

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ module.exports = {
2323
// Make alias available as ${self:provider.alias}
2424
this._serverless.service.provider.alias = this._alias;
2525

26+
// Set SERVERLESS_ALIAS environment variable to let other plugins access it during the build
27+
process.env.SERVERLESS_ALIAS = this._alias;
28+
2629
// Parse and check plugin options
2730
if (this._options['alias-resources']) {
2831
this._aliasResources = true;

test/validate.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ describe('#validate()', () => {
5656
]));
5757
});
5858

59+
it('should set SERVERLESS_ALIAS', () => {
60+
return expect(awsAlias.validate()).to.eventually.be.fulfilled
61+
.then(() => expect(process.env.SERVERLESS_ALIAS).to.equal('myStage'));
62+
});
63+
5964
it('should succeed', () => {
6065
return expect(awsAlias.validate()).to.eventually.be.fulfilled;
6166
});

0 commit comments

Comments
 (0)