diff --git a/README.md b/README.md index 153afec..6883998 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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` diff --git a/index.js b/index.js index 368ae01..a315add 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -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; }