From c79e27fece2146c543926b2632e3b30f2ab16103 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Fri, 16 Aug 2019 18:51:57 +0200 Subject: [PATCH] fix: Crash deployment if function app zip file doesn't exist (#242) --- src/plugins/deploy/azureDeployPlugin.test.ts | 6 ++++++ src/plugins/deploy/azureDeployPlugin.ts | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/deploy/azureDeployPlugin.test.ts b/src/plugins/deploy/azureDeployPlugin.test.ts index 7b1f3e00..c17bd4ad 100644 --- a/src/plugins/deploy/azureDeployPlugin.test.ts +++ b/src/plugins/deploy/azureDeployPlugin.test.ts @@ -64,4 +64,10 @@ describe("Deploy plugin", () => { expect(ResourceService.prototype.listDeployments).toBeCalled(); expect(sls.cli.log).lastCalledWith(deploymentString); }); + + it("crashes deploy if zip file is not found", async () => { + FunctionAppService.prototype.getFunctionZipFile = jest.fn(() => "notExisting.zip"); + await expect(invokeHook(plugin, "deploy:deploy")) + .rejects.toThrow(/Function app zip file '.*' does not exist/) + }); }); diff --git a/src/plugins/deploy/azureDeployPlugin.ts b/src/plugins/deploy/azureDeployPlugin.ts index 8e385603..ff9d60fd 100644 --- a/src/plugins/deploy/azureDeployPlugin.ts +++ b/src/plugins/deploy/azureDeployPlugin.ts @@ -56,8 +56,7 @@ export class AzureDeployPlugin extends AzureBasePlugin { const functionAppService = new FunctionAppService(this.serverless, this.options); const zipFile = functionAppService.getFunctionZipFile(); if (!fs.existsSync(zipFile)) { - this.log(`Function app zip file '${zipFile}' does not exist`); - return Promise.resolve(); + throw new Error(`Function app zip file '${zipFile}' does not exist`); } await resourceService.deployResourceGroup(); const functionApp = await functionAppService.deploy();