Skip to content

Commit beb3393

Browse files
authored
Merge pull request #2 from Ryan-Gordon/feat/cargo-workspace
feat(cargo): Add support for cargo workspace
2 parents d6f4492 + 84a17b4 commit beb3393

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ functions:
6262

6363
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.
6464

65+
## Use with cargo workspaces
66+
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.
67+
6568
## 🖍️ customize
6669

6770
You can optionally adjust the default settings of the dockerized build env using
@@ -78,6 +81,8 @@ custom:
7881
dockerTag: 'some-custom-tag'
7982
# custom docker image
8083
dockerImage: 'dockerUser/dockerRepo'
84+
# Using a workspace?
85+
inWorkspace: true # <---- Defaults to false
8186
```
8287

8388
### 🥼 (experimental) local builds

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class RustPlugin {
4848
dockerImage: DEFAULT_DOCKER_IMAGE,
4949
dockerless: false,
5050
strictMode: true,
51+
inWorkspace: false,
5152
},
5253
(this.serverless.service.custom && this.serverless.service.custom.rust) ||
5354
{},
@@ -168,7 +169,7 @@ class RustPlugin {
168169
const zip = new AdmZip();
169170
zip.addFile(
170171
"bootstrap",
171-
readFileSync(path.join(sourceDir, binary)),
172+
readFileSync(path.join(this.custom.inWorkspace ? '..' : '', sourceDir, binary)),
172173
"",
173174
0o755,
174175
);

tests/unit/index.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe("RustPlugin", () => {
4242
dockerTag: "latest",
4343
dockerless: false,
4444
strictMode: true,
45+
inWorkspace: false
4546
});
4647
});
4748

@@ -57,6 +58,7 @@ describe("RustPlugin", () => {
5758
dockerTag: "custom-tag",
5859
dockerless: true,
5960
strictMode: false,
61+
inWorkspace: false
6062
},
6163
},
6264
package: {},
@@ -71,6 +73,7 @@ describe("RustPlugin", () => {
7173
dockerTag: "custom-tag",
7274
dockerless: true,
7375
strictMode: false,
76+
inWorkspace: false
7477
});
7578
});
7679

0 commit comments

Comments
 (0)