From f1953fef3ffb3f2b913b170dde738fe63b5db592 Mon Sep 17 00:00:00 2001 From: "Joel S. Roxell" Date: Thu, 4 Aug 2022 19:12:58 +0200 Subject: [PATCH] feat: support builds from a cargo workspace --- index.js | 3 ++- tests/unit/index.test.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 58f330b..557e33b 100644 --- a/index.js +++ b/index.js @@ -47,6 +47,7 @@ class RustPlugin { dockerTag: DEFAULT_DOCKER_TAG, dockerImage: DEFAULT_DOCKER_IMAGE, dockerless: false, + inWorkspace: false, }, (this.serverless.service.custom && this.serverless.service.custom.rust) || {} @@ -167,7 +168,7 @@ class RustPlugin { const zip = new AdmZip(); zip.addFile( "bootstrap", - readFileSync(path.join(sourceDir, binary)), + readFileSync(path.join(this.custom.inWorkspace ? '..' : '', sourceDir, binary)), "", 0o755 ); diff --git a/tests/unit/index.test.js b/tests/unit/index.test.js index 28714cd..38200bb 100644 --- a/tests/unit/index.test.js +++ b/tests/unit/index.test.js @@ -40,6 +40,7 @@ describe("RustPlugin", () => { dockerImage: "softprops/lambda-rust", dockerTag: "latest", dockerless: false, + inWorkspace: false }); }); @@ -54,6 +55,7 @@ describe("RustPlugin", () => { dockerImage: "notsoftprops/lambda-rust", dockerTag: "custom-tag", dockerless: true, + inWorkspace: false }, }, package: {}, @@ -67,6 +69,7 @@ describe("RustPlugin", () => { dockerImage: "notsoftprops/lambda-rust", dockerTag: "custom-tag", dockerless: true, + inWorkspace: false }); });