@@ -161,7 +161,7 @@ export class ServerlessPlugin {
161
161
}
162
162
}
163
163
164
- async cleanup ( ) : Promise < void > {
164
+ async moveArtifacts ( ) : Promise < void > {
165
165
await fs . copy (
166
166
path . join ( this . originalServicePath , buildFolder , serverlessFolder ) ,
167
167
path . join ( this . originalServicePath , serverlessFolder )
@@ -170,12 +170,35 @@ export class ServerlessPlugin {
170
170
if ( this . options . function ) {
171
171
const fn = this . serverless . service . functions [ this . options . function ]
172
172
const basename = path . basename ( fn . package . artifact )
173
- fn . package . artifact = path . join ( this . originalServicePath , serverlessFolder , basename )
174
- } else {
175
- const basename = path . basename ( this . serverless . service . package . artifact )
176
- this . serverless . service . package . artifact = path . join ( this . originalServicePath , serverlessFolder , basename )
173
+ fn . package . artifact = path . join (
174
+ this . originalServicePath ,
175
+ serverlessFolder ,
176
+ path . basename ( fn . package . artifact )
177
+ )
178
+ return
179
+ }
180
+
181
+ if ( this . serverless . service . package . individually ) {
182
+ const functionNames = this . serverless . service . getAllFunctions ( )
183
+ functionNames . forEach ( name => {
184
+ this . serverless . service . functions [ name ] . package . artifact = path . join (
185
+ this . originalServicePath ,
186
+ serverlessFolder ,
187
+ path . basename ( this . serverless . service . functions [ name ] . package . artifact )
188
+ )
189
+ } )
190
+ return
177
191
}
178
192
193
+ this . serverless . service . package . artifact = path . join (
194
+ this . originalServicePath ,
195
+ serverlessFolder ,
196
+ path . basename ( this . serverless . service . package . artifact )
197
+ )
198
+ }
199
+
200
+ async cleanup ( ) : Promise < void > {
201
+ await this . moveArtifacts ( )
179
202
// Restore service path
180
203
this . serverless . config . servicePath = this . originalServicePath
181
204
// Remove temp build folder
0 commit comments