diff --git a/README.md b/README.md index d1ab4f5..8d827cf 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,9 @@ functions: The default behavior is to build your lambda inside a docker container. Make sure you have a docker daemon running if you are not opting into the dockerless mode. +## Use with cargo workspaces +Workspaces and per workspace serverless files are now supported. To use it, a custom flag has been added to signal that the serverless.yml is nested in a cargo workspace. Since the binaries will be outputted to a target folder in the workspace root, the zip-copy-process needs to take that into account. + ## 🖍️ customize You can optionally adjust the default settings of the dockerized build env using @@ -78,6 +81,8 @@ custom: dockerTag: 'some-custom-tag' # custom docker image dockerImage: 'dockerUser/dockerRepo' + # Using a workspace? + inWorkspace: true # <---- Defaults to false ``` ### 🥼 (experimental) local builds diff --git a/index.js b/index.js index 23ac35e..e91d575 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,7 @@ class RustPlugin { dockerImage: DEFAULT_DOCKER_IMAGE, dockerless: false, strictMode: true, + inWorkspace: false, }, (this.serverless.service.custom && this.serverless.service.custom.rust) || {}, @@ -168,7 +169,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 a3ff5b7..1ff77fd 100644 --- a/tests/unit/index.test.js +++ b/tests/unit/index.test.js @@ -42,6 +42,7 @@ describe("RustPlugin", () => { dockerTag: "latest", dockerless: false, strictMode: true, + inWorkspace: false }); }); @@ -57,6 +58,7 @@ describe("RustPlugin", () => { dockerTag: "custom-tag", dockerless: true, strictMode: false, + inWorkspace: false }, }, package: {}, @@ -71,6 +73,7 @@ describe("RustPlugin", () => { dockerTag: "custom-tag", dockerless: true, strictMode: false, + inWorkspace: false }); });