From 2e2ddd5b9fea916d9ed50f59db212fc7a2e70efe Mon Sep 17 00:00:00 2001 From: Konstantin Tennhard Date: Tue, 16 Nov 2021 10:15:54 -0500 Subject: [PATCH] ESBuild status messages and errors ESBuild status messages and errors are now directly presented to the user rather than being obfuscated by a generic message. --- lib/project_types/extension/commands/build.rb | 11 +++-------- lib/project_types/extension/messages/messages.rb | 3 --- .../extension/models/development_server.rb | 4 ++-- .../extension/models/development_server_test.rb | 5 +++-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/project_types/extension/commands/build.rb b/lib/project_types/extension/commands/build.rb index 262ca5aa72..f7a9a27799 100644 --- a/lib/project_types/extension/commands/build.rb +++ b/lib/project_types/extension/commands/build.rb @@ -24,21 +24,16 @@ def self.help private def run_new_flow(project) - Tasks::RunExtensionCommand.new( + output = Tasks::RunExtensionCommand.new( type: project.specification_identifier.downcase, command: "build", config_file_name: specification_handler.server_config_file, context: @ctx, ).call - @ctx.puts(@ctx.message("build.build_success_message")) + @ctx.puts(output) rescue => error - if error.message.include?("no such file or directory") - @ctx.abort(@ctx.message("build.directory_not_found")) - else - @ctx.debug(error) - @ctx.abort(@ctx.message("build.build_failure_message")) - end + @ctx.abort(error.message) end def run_legacy_flow diff --git a/lib/project_types/extension/messages/messages.rb b/lib/project_types/extension/messages/messages.rb index de6198d58c..cfd77334db 100644 --- a/lib/project_types/extension/messages/messages.rb +++ b/lib/project_types/extension/messages/messages.rb @@ -67,9 +67,6 @@ module Messages Usage: {{command:%s extension build}} HELP frame_title: "Building extension with: %s…", - build_failure_message: "Failed to build extension code.", - build_success_message: "Build was successful!", - directory_not_found: "Build directory not found.", }, register: { help: <<~HELP, diff --git a/lib/project_types/extension/models/development_server.rb b/lib/project_types/extension/models/development_server.rb index e5ec445f3b..265ffc58f4 100644 --- a/lib/project_types/extension/models/development_server.rb +++ b/lib/project_types/extension/models/development_server.rb @@ -33,8 +33,8 @@ def create(server_config) end def build(server_config) - _, error, status = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml) - return if status.success? + output, error, status = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml) + return output if status.success? raise DevelopmentServerError, error end diff --git a/test/project_types/extension/models/development_server_test.rb b/test/project_types/extension/models/development_server_test.rb index 00785b8da0..fbf6b3ec9f 100644 --- a/test/project_types/extension/models/development_server_test.rb +++ b/test/project_types/extension/models/development_server_test.rb @@ -32,9 +32,10 @@ def test_build_calls_executable_and_is_successful CLI::Kit::System.expects(:capture3) .with(@development_server.executable, "build", "-", stdin_data: server_config.to_yaml) - .returns(["", nil, mock(success?: true)]) + .returns(["some output", nil, mock(success?: true)]) - @development_server.build(server_config) + output = @development_server.build(server_config) + assert_equal "some output", output end end