From c46f7b8a97a407a1cc6ec2138bcf471e9a8daaf0 Mon Sep 17 00:00:00 2001 From: Juanjo Diaz Date: Fri, 19 Feb 2021 20:04:54 +0100 Subject: [PATCH] refactor: replace `after:package:initialize` by `'before:package:createDeploymentArtifacts` --- README.md | 2 +- src/index.js | 2 +- test/hook.warmupAddWamersAddWamers.test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5021795..d16ac20 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ end WarmUp plugin uses 3 lifecycles hooks: -* `warmup:addWamers:addWamers`: This is where the warmers are added to the service. It runs `after:package:initialize`. +* `warmup:addWamers:addWamers`: This is where the warmers are added to the service. It runs `before:package:createDeploymentArtifacts`. * `warmup:cleanupTempDir:cleanup`: This is where the warmers' temp folders are removed. It runs `after:package:createDeploymentArtifacts`. * `warmup:prewarm:start`: This is where the warmers are invoked. It runs `after:deploy:deploy` or when running the command `serverless warmup prewarm`. * `warmup:prewarm:end`: This is after the warmers are invoked. diff --git a/src/index.js b/src/index.js index 0d1026e..7d66ad0 100644 --- a/src/index.js +++ b/src/index.js @@ -59,7 +59,7 @@ class WarmUp { }; this.hooks = { - 'after:package:initialize': () => this.serverless.pluginManager.spawn('warmup:addWamers'), + 'before:package:createDeploymentArtifacts': () => this.serverless.pluginManager.spawn('warmup:addWamers'), 'after:package:createDeploymentArtifacts': () => this.serverless.pluginManager.spawn('warmup:cleanupTempDir'), 'after:deploy:deploy': () => this.serverless.pluginManager.spawn('warmup:prewarm'), 'before:warmup:addWamers:addWamers': this.configPlugin.bind(this), diff --git a/test/hook.warmupAddWamersAddWamers.test.js b/test/hook.warmupAddWamersAddWamers.test.js index 0d7cca7..e4134cd 100644 --- a/test/hook.warmupAddWamersAddWamers.test.js +++ b/test/hook.warmupAddWamersAddWamers.test.js @@ -50,7 +50,7 @@ describe('Serverless warmup plugin warmup:warmers:addWamers:addWamers hook', () }); const plugin = new WarmUp(serverless, {}); - await plugin.hooks['after:package:initialize'](); + await plugin.hooks['before:package:createDeploymentArtifacts'](); expect(serverless.pluginManager.spawn).toHaveBeenCalledTimes(1); expect(serverless.pluginManager.spawn).toHaveBeenCalledWith('warmup:addWamers');