@@ -133,14 +133,12 @@ struct AWSLambdaPackager: CommandPlugin {
133
133
// because Examples' Package.swift have a dependency on ../..
134
134
// just like Package.swift's examples assume ../.., we assume we are two levels below the root project
135
135
let slice = packageDirectory. pathComponents. suffix ( 2 )
136
- let beforeLastComponent = packageDirectory. pathComponents [ slice. startIndex]
137
- let lastComponent = packageDirectory. pathComponents [ slice. endIndex - 1 ]
138
136
try Utils . execute (
139
137
executable: dockerToolPath,
140
138
arguments: [
141
139
" run " , " --rm " , " --env " , " LAMBDA_USE_LOCAL_DEPS=true " , " -v " ,
142
140
" \( packageDirectory. path ( ) ) ../..:/workspace " , " -w " ,
143
- " /workspace/ \( beforeLastComponent ) / \( lastComponent ) " , baseImage, " bash " , " -cl " , buildCommand,
141
+ " /workspace/ \( slice . joined ( separator : " / " ) ) " , baseImage, " bash " , " -cl " , buildCommand,
144
142
] ,
145
143
logLevel: verboseLogging ? . debug : . output
146
144
)
@@ -237,17 +235,26 @@ struct AWSLambdaPackager: CommandPlugin {
237
235
238
236
// add resources
239
237
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
+ }
251
258
}
252
259
253
260
// run the zip tool
0 commit comments