Skip to content

Commit

Permalink
Raise BuildError when EmberCLI app fails to build
Browse files Browse the repository at this point in the history
Fix #23
  • Loading branch information
rwz committed Jan 20, 2015
1 parent 0edf718 commit bba01ec
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/ember-cli/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class App
ADDON_VERSION = "0.0.9"
EMBER_CLI_VERSION = "~> 0.1.5"

class BuildError < StandardError; end

attr_reader :name, :options, :pid

def initialize(name, options={})
Expand Down Expand Up @@ -42,7 +44,7 @@ def exposed_css_assets

def wait
Timeout.timeout(build_timeout) do
sleep 0.1 while lockfile.exist?
wait_for_build_complete_or_error
end
rescue Timeout::Error
suggested_timeout = build_timeout + 5
Expand Down Expand Up @@ -93,10 +95,21 @@ def lockfile
tmp_path.join("build.lock")
end

def build_error_file
tmp_path.join("error.txt")
end

def raise_build_error!
error = BuildError.new("EmberCLI app #{name.inspect} has failed to build")
error.set_backtrace build_error_file.read.split(?\n)
fail error
end

def prepare
@prepared ||= begin
check_addon!
check_ember_cli_version!
build_error_file.delete if build_error_file.exist?
FileUtils.touch lockfile
symlink_to_assets_root
add_assets_to_precompile_list
Expand Down Expand Up @@ -219,5 +232,13 @@ def exec(cmd, options={})
Kernel.public_send(method_name, env_hash, cmd, err: :out)
end
end

def wait_for_build_complete_or_error
loop do
raise_build_error! if build_error_file.exist?
break unless lockfile.exist?
sleep 0.1
end
end
end
end

0 comments on commit bba01ec

Please sign in to comment.