Skip to content

Commit

Permalink
Merge pull request #21 from mihaerzen/master
Browse files Browse the repository at this point in the history
Add autoInvalidate prop to the cloudfrontInvalidate
  • Loading branch information
aghadiry authored Jan 18, 2021
2 parents 52285ca + 28ff6e9 commit 5c0b5e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ custom:
cloudfrontInvalidate:
- distributionId: "CLOUDFRONT_DIST_ID" #conditional, distributionId or distributionIdKey is required.
distributionIdKey: "CDNDistributionId" #conditional, distributionId or distributionIdKey is required.
autoInvalidate: true # Can be set to false to avoid automatic invalidation after the deployment. Useful if you want to manually trigger the invalidation later. Defaults to true.
items: # one or more paths required
- "/index.html"
stage: "dev" # conditional, the stage that this cloudfront invalidation should be created
Expand Down Expand Up @@ -76,7 +77,7 @@ You can communicate with AWS even if you are using a proxy by setting the proxy
- HTTPS_PROXY
- https_proxy

- exsample
- example

windows: `set HTTP_PROXY=http://localhost:8080`

Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ class CloudfrontInvalidate {
};

this.hooks = {
'after:deploy:deploy': this.invalidate.bind(this),
'cloudfrontInvalidate:invalidate': this.invalidate.bind(this),
};

if (serverless.service.custom.cloudfrontInvalidate.autoInvalidate !== false) {
this.hooks['after:deploy:deploy'] = this.invalidate.bind(this)
}
}

setProxy(proxyURL) {
Expand Down Expand Up @@ -82,7 +85,7 @@ class CloudfrontInvalidate {
cli.consoleLog(`CloudfrontInvalidate: ${chalk.yellow('Invalidation started')}`);
},
err => {
console.log(JSON.stringify(err));
cli.consoleLog(JSON.stringify(err));
cli.consoleLog(`CloudfrontInvalidate: ${chalk.yellow('Invalidation failed')}`);
throw err;
}
Expand Down

0 comments on commit 5c0b5e9

Please sign in to comment.