@@ -93,7 +93,10 @@ struct AWSLambdaPackager: CommandPlugin {
9393 arguments: [ " run " , " --rm " , " --pull " , " always " , " -v " , " \( packageDirectory. string) :/workspace " , " -w " , " /workspace " , baseImage, " bash " , " -cl " , buildOutputPathCommand] ,
9494 logLevel: verboseLogging ? . debug : . silent
9595 )
96- let buildOutputPath = Path ( dockerBuildOutputPath. replacingOccurrences ( of: " /workspace " , with: packageDirectory. string) )
96+ guard let buildPathOutput = dockerBuildOutputPath. split ( separator: " \n " ) . last else {
97+ throw Errors . failedParsingDockerOutput ( dockerBuildOutputPath)
98+ }
99+ let buildOutputPath = Path ( buildPathOutput. replacingOccurrences ( of: " /workspace " , with: packageDirectory. string) )
97100
98101 // build the products
99102 var builtProducts = [ LambdaProduct: Path] ( )
@@ -107,7 +110,7 @@ struct AWSLambdaPackager: CommandPlugin {
107110 )
108111 let productPath = buildOutputPath. appending ( product. name)
109112 guard FileManager . default. fileExists ( atPath: productPath. string) else {
110- print ( " expected ' \( product. name) ' binary at \" \( productPath. string) \" " )
113+ Diagnostics . error ( " expected ' \( product. name) ' binary at \" \( productPath. string) \" " )
111114 throw Errors . productExecutableNotFound ( product. name)
112115 }
113116 builtProducts [ . init( product) ] = productPath
@@ -219,7 +222,7 @@ struct AWSLambdaPackager: CommandPlugin {
219222 print ( _output)
220223 fflush ( stdout)
221224 }
222- output += _output
225+ output += _output + " \n "
223226 }
224227
225228 let pipe = Pipe ( )
@@ -239,12 +242,19 @@ struct AWSLambdaPackager: CommandPlugin {
239242 }
240243 }
241244
245+ print ( 0 )
246+
242247 try process. run ( )
243248 process. waitUntilExit ( )
244249
250+ // FIXME: debug
251+ print ( 1 )
252+
245253 // wait for output to be full processed
246254 outputSync. wait ( )
247255
256+ print ( 2 )
257+
248258 if process. terminationStatus != 0 {
249259 // print output on failure and if not already printed
250260 if logLevel < . output {
@@ -364,6 +374,7 @@ private enum Errors: Error, CustomStringConvertible {
364374 case unknownProduct( String )
365375 case productExecutableNotFound( String )
366376 case failedWritingDockerfile
377+ case failedParsingDockerOutput( String )
367378 case processFailed( [ String ] , Int32 )
368379
369380 var description : String {
@@ -378,6 +389,8 @@ private enum Errors: Error, CustomStringConvertible {
378389 return " product executable not found ' \( product) ' "
379390 case . failedWritingDockerfile:
380391 return " failed writing dockerfile "
392+ case . failedParsingDockerOutput( let output) :
393+ return " failed parsing docker output: ' \( output) ' "
381394 case . processFailed( let arguments, let code) :
382395 return " \( arguments. joined ( separator: " " ) ) failed with code \( code) "
383396 }
0 commit comments