diff --git a/lib/validate.js b/lib/validate.js index de29d14..2f446bb 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -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; diff --git a/test/validate.test.js b/test/validate.test.js index 3caba11..bf089d7 100644 --- a/test/validate.test.js +++ b/test/validate.test.js @@ -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; });