Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoInvalidate prop to the cloudfrontInvalidate #21

Merged
merged 3 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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