Skip to content

Commit

Permalink
Fix regression in Serverless that caused the plugin to fail
Browse files Browse the repository at this point in the history
> TypeError: Cannot read property 'bref' of undefined
  • Loading branch information
mnapoli committed Jun 11, 2021
1 parent af366b5 commit 71f8821
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ class ServerlessPlugin {
return delegate(variableString);
}

// Check if bref custom directive is set, otherwise initialize it with empty object
this.serverless.service.custom = this.serverless.service.custom ? this.serverless.service.custom : {};
this.serverless.service.custom.bref = this.serverless.service.custom.bref ? this.serverless.service.custom.bref : {};

this.hooks = {
'before:package:setupProviderConfiguration': this.addCustomIamRoleForVendorArchiveDownload.bind(this),
'package:setupProviderConfiguration': this.createVendorZip.bind(this),
Expand All @@ -95,7 +91,9 @@ class ServerlessPlugin {
}

addCustomIamRoleForVendorArchiveDownload() {
if(! this.serverless.service.custom.bref.separateVendor) {
this.serverless.service.custom = this.serverless.service.custom ? this.serverless.service.custom : {};
this.serverless.service.custom.bref = this.serverless.service.custom.bref ? this.serverless.service.custom.bref : {};
if (! this.serverless.service.custom.bref.separateVendor) {
return;
}

Expand Down Expand Up @@ -139,6 +137,8 @@ class ServerlessPlugin {
}

async createVendorZip() {
this.serverless.service.custom = this.serverless.service.custom ? this.serverless.service.custom : {};
this.serverless.service.custom.bref = this.serverless.service.custom.bref ? this.serverless.service.custom.bref : {};
if(! this.serverless.service.custom.bref.separateVendor) {
return;
}
Expand Down Expand Up @@ -222,6 +222,8 @@ class ServerlessPlugin {
}

async uploadVendorZip() {
this.serverless.service.custom = this.serverless.service.custom ? this.serverless.service.custom : {};
this.serverless.service.custom.bref = this.serverless.service.custom.bref ? this.serverless.service.custom.bref : {};
if(! this.serverless.service.custom.bref.separateVendor) {
return;
}
Expand Down

0 comments on commit 71f8821

Please sign in to comment.