@@ -161,7 +161,7 @@ export class ServerlessPlugin {
161161 }
162162 }
163163
164- async cleanup ( ) : Promise < void > {
164+ async moveArtifacts ( ) : Promise < void > {
165165 await fs . copy (
166166 path . join ( this . originalServicePath , buildFolder , serverlessFolder ) ,
167167 path . join ( this . originalServicePath , serverlessFolder )
@@ -170,12 +170,35 @@ export class ServerlessPlugin {
170170 if ( this . options . function ) {
171171 const fn = this . serverless . service . functions [ this . options . function ]
172172 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
177191 }
178192
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 ( )
179202 // Restore service path
180203 this . serverless . config . servicePath = this . originalServicePath
181204 // Remove temp build folder
0 commit comments