@@ -132,15 +132,13 @@ struct AWSLambdaPackager: CommandPlugin {
132132 // when developing locally, we must have the full swift-aws-lambda-runtime project in the container
133133 // because Examples' Package.swift have a dependency on ../..
134134 // just like Package.swift's examples assume ../.., we assume we are two levels below the root project
135- let slice = packageDirectory. pathComponents. suffix ( 2 )
136- let beforeLastComponent = packageDirectory. pathComponents [ slice. startIndex]
137- let lastComponent = packageDirectory. pathComponents [ slice. endIndex - 1 ]
135+ let slice = packageDirectory. pathComponents. suffix ( 3 )
138136 try Utils . execute (
139137 executable: dockerToolPath,
140138 arguments: [
141139 " run " , " --rm " , " --env " , " LAMBDA_USE_LOCAL_DEPS=true " , " -v " ,
142- " \( packageDirectory. path ( ) ) ../..:/workspace " , " -w " ,
143- " /workspace/ \( beforeLastComponent ) / \( lastComponent ) " , baseImage, " bash " , " -cl " , buildCommand,
140+ " \( packageDirectory. path ( ) ) ../../.. :/workspace " , " -w " ,
141+ " /workspace/ \( slice . joined ( separator : " / " ) ) " , baseImage, " bash " , " -cl " , buildCommand,
144142 ] ,
145143 logLevel: verboseLogging ? . debug : . output
146144 )
@@ -237,18 +235,28 @@ struct AWSLambdaPackager: CommandPlugin {
237235
238236 // add resources
239237 var artifactPathComponents = artifactPath. pathComponents
240- _ = artifactPathComponents. removeLast ( )
241- let artifactDirectory = artifactPathComponents. joined ( separator: " / " )
242- let resourcesDirectoryName = " \( packageName) _ \( product. name) .resources "
243- let resourcesDirectory = artifactDirectory. appending ( resourcesDirectoryName)
244- let relocatedResourcesDirectory = workingDirectory. appending ( path: resourcesDirectoryName)
245- if FileManager . default. fileExists ( atPath: resourcesDirectory) {
246- try FileManager . default. copyItem (
247- atPath: resourcesDirectory,
248- toPath: relocatedResourcesDirectory. path ( )
249- )
250- arguments. append ( resourcesDirectoryName)
238+ _ = artifactPathComponents. removeFirst ( ) // Get rid of beginning "/"
239+ _ = artifactPathComponents. removeLast ( ) // Get rid of the name of the package
240+ let artifactDirectory = " / \( artifactPathComponents. joined ( separator: " / " ) ) "
241+ for fileInArtifactDirectory in try FileManager . default. contentsOfDirectory ( atPath: artifactDirectory) {
242+ guard let artifactURL = URL ( string: " \( artifactDirectory) / \( fileInArtifactDirectory) " ) else {
243+ continue
244+ }
245+
246+ guard artifactURL. pathExtension == " resources " else {
247+ continue // Not resources, so don't copy
248+ }
249+ let resourcesDirectoryName = artifactURL. lastPathComponent
250+ let relocatedResourcesDirectory = workingDirectory. appending ( path: resourcesDirectoryName)
251+ if FileManager . default. fileExists ( atPath: artifactURL. path ( ) ) {
252+ try FileManager . default. copyItem (
253+ atPath: artifactURL. path ( ) ,
254+ toPath: relocatedResourcesDirectory. path ( )
255+ )
256+ arguments. append ( resourcesDirectoryName)
257+ }
251258 }
259+
252260
253261 // run the zip tool
254262 try Utils . execute (
0 commit comments