Skip to content

Commit

Permalink
Bugfix when removing a stack
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jan 19, 2021
1 parent f6dec21 commit 02c1ab0
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,27 +230,18 @@ class ServerlessPlugin {
* That's why we clean up the vendor zip files when `serverless remove` is being run.
*/
async removeVendorArchives() {
this.consoleLog('Removing vendor archives from S3 bucket.');

const bucketName = await this.provider.getServerlessDeploymentBucketName();
const deploymentPrefix = await this.provider.getDeploymentPrefix();

let bucketObjects = [];
try {
bucketObjects = await this.provider.request('S3', 'listObjectsV2', {
Bucket: bucketName,
Prefix: this.stripSlashes(deploymentPrefix + '/vendors/')
});
} catch(e) {
this.consoleLog('Bucket not found, nothing to delete, all is good.');
const bucketObjects = await this.provider.request('S3', 'listObjectsV2', {
Bucket: bucketName,
Prefix: this.stripSlashes(deploymentPrefix + '/vendors/')
});
if (bucketObjects.Contents.length === 0) {
return;
}


if(bucketObjects.length === 0) {
this.consoleLog('No vendor archives found, all is good.');
return;
}
this.consoleLog('Removing Composer `vendor` archives from the S3 bucket.');

let details = {
Bucket: bucketName,
Expand Down

0 comments on commit 02c1ab0

Please sign in to comment.