Skip to content

Commit c7def7d

Browse files
committed
hoist profile one level to that it can be used in package extraction
1 parent fb7d18d commit c7def7d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class RustPlugin {
5050
this.serverless.service.package.excludeDevDependencies = false;
5151
}
5252

53-
runDocker(funcArgs, cargoPackage, binary) {
53+
runDocker(funcArgs, cargoPackage, binary, profile) {
5454
const cargoHome = process.env.CARGO_HOME || path.join(homedir(), ".cargo");
5555
const cargoRegistry = path.join(cargoHome, "registry");
5656
const cargoDownloads = path.join(cargoHome, "git");
@@ -70,7 +70,6 @@ class RustPlugin {
7070
const customArgs = [];
7171

7272
let cargoFlags = (funcArgs || {}).cargoFlags || this.custom.cargoFlags;
73-
let profile = (funcArgs || {}).profile || this.custom.profile;
7473
if (profile) {
7574
// release or dev
7675
customArgs.push("-e", `PROFILE=${profile}`);
@@ -121,7 +120,8 @@ class RustPlugin {
121120
binary = cargoPackage;
122121
}
123122
this.serverless.cli.log(`Building native Rust ${func.handler} func...`);
124-
const res = this.runDocker(func.rust, cargoPackage, binary);
123+
let profile = (func.rust || {}).profile || this.custom.profile;
124+
const res = this.runDocker(func.rust, cargoPackage, binary, profile);
125125
if (res.error || res.status > 0) {
126126
this.serverless.cli.log(
127127
`Dockerized Rust build encountered an error: ${res.error} ${res.status}.`
@@ -137,7 +137,7 @@ class RustPlugin {
137137
// we leverage the ability to declare a package artifact directly
138138
// see https://serverless.com/framework/docs/providers/aws/guide/packaging/
139139
// for more information
140-
const artifactPath = path.join("target/lambda/release", binary + ".zip");
140+
const artifactPath = path.join(`target/lambda/${'dev' === profile ? 'debug' : 'release'}`, binary + ".zip");
141141
func.package = func.package || {};
142142
func.package.artifact = artifactPath;
143143

0 commit comments

Comments
 (0)