@@ -128,11 +128,15 @@ struct AWSLambdaPackager: CommandPlugin {
128128                // when developing locally, we must have the full swift-aws-lambda-runtime project in the container
129129                // because Examples' Package.swift have a dependency on ../..
130130                // just like Package.swift's examples assume ../.., we assume we are two levels below the root project
131-                 let  lastComponent  =  packageDirectory. lastComponent 
132-                 let  beforeLastComponent  =  packageDirectory . removingLastComponent ( ) . lastComponent 
131+                 let  packageDirectoryURL  =  URL ( string :   packageDirectory. string ) ! 
132+                 let  slice  =  packageDirectoryURL . pathComponents . suffix ( 2 ) 
133133                try self . execute ( 
134134                    executable:  dockerToolPath, 
135-                     arguments:  [ " run " ,  " --rm " ,  " --env " ,  " LAMBDA_USE_LOCAL_DEPS=true " ,  " -v " ,  " \( packageDirectory. string) /../..:/workspace " ,  " -w " ,  " /workspace/ \( beforeLastComponent) / \( lastComponent) " ,  baseImage,  " bash " ,  " -cl " ,  buildCommand] , 
135+                     arguments:  [ 
136+                         " run " ,  " --rm " ,  " --env " ,  " LAMBDA_USE_LOCAL_DEPS=true " ,  " -v " , 
137+                         " \( packageDirectory) ../..:/workspace " ,  " -w " , 
138+                         " /workspace/ \( slice. joined ( separator:  " / " ) ) " ,  baseImage,  " bash " ,  " -cl " ,  buildCommand, 
139+                     ] , 
136140                    logLevel:  verboseLogging ?  . debug :  . output
137141                ) 
138142            }  else  { 
@@ -226,13 +230,27 @@ struct AWSLambdaPackager: CommandPlugin {
226230            #endif 
227231
228232            // add resources
229-             let  artifactDirectory  =  artifactPath. removingLastComponent ( ) 
230-             let  resourcesDirectoryName  =  " \( packageName) _ \( product. name) .resources " 
231-             let  resourcesDirectory  =  artifactDirectory. appending ( resourcesDirectoryName) 
232-             let  relocatedResourcesDirectory  =  workingDirectory. appending ( resourcesDirectoryName) 
233-             if  FileManager . default. fileExists ( atPath:  resourcesDirectory. string)  { 
234-                 try FileManager . default. copyItem ( atPath:  resourcesDirectory. string,  toPath:  relocatedResourcesDirectory. string) 
235-                 arguments. append ( resourcesDirectoryName) 
233+             var  artifactPathComponents  =  URL ( string:  artifactPath. string) !. pathComponents
234+             _ =  artifactPathComponents. removeFirst ( )   // Get rid of beginning "/"
235+             _ =  artifactPathComponents. removeLast ( )   // Get rid of the name of the package
236+             let  artifactDirectory  =  " / \( artifactPathComponents. joined ( separator:  " / " ) ) " 
237+             for  fileInArtifactDirectory  in  try FileManager . default. contentsOfDirectory ( atPath:  artifactDirectory)  { 
238+                 guard  let  artifactURL =  URL ( string:  " \( artifactDirectory) / \( fileInArtifactDirectory) " )  else  { 
239+                     continue 
240+                 } 
241+ 
242+                 guard  artifactURL. pathExtension ==  " resources "  else  { 
243+                     continue   // Not resources, so don't copy
244+                 } 
245+                 let  resourcesDirectoryName  =  artifactURL. lastPathComponent
246+                 let  relocatedResourcesDirectory  =  workingDirectory. appending ( resourcesDirectoryName) 
247+                 if  FileManager . default. fileExists ( atPath:  artifactURL. path ( ) )  { 
248+                     try FileManager . default. copyItem ( 
249+                         atPath:  artifactURL. path ( ) , 
250+                         toPath:  relocatedResourcesDirectory. string
251+                     ) 
252+                     arguments. append ( resourcesDirectoryName) 
253+                 } 
236254            } 
237255
238256            // run the zip tool
0 commit comments