Skip to content

Commit

Permalink
Merge branch 'master' into 0.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Dec 16, 2015
2 parents ff017a6 + 50a1f6d commit e18fa83
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/lotus/assets/precompiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ def initialize(configuration, duplicates)
end

def run
clear_public_directory
precompile
end

private

def clear_public_directory
public_directory = Lotus::Assets.configuration.public_directory
public_directory.rmtree if public_directory.exist?
end

def precompile
applications.each do |duplicate|
config = duplicate.configuration
config.compile true
Expand All @@ -19,8 +31,6 @@ def run
end
end

private

def applications
@duplicates.empty? ?
[Lotus::Assets] : @duplicates
Expand Down
22 changes: 22 additions & 0 deletions test/integration/precompile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
assert_successful_command "#{ __dir__ }/../fixtures/standalone/config/environment.rb"
assert_successful_output(assets)
end

describe "when already precompiled " do
it "cleans up the destination directory before to precompile" do
2.times do
assert_successful_command "#{ __dir__ }/../fixtures/standalone/config/environment.rb"
end

duplicated_manifests = Dir[dest.join('assets-*.json').to_s]
duplicated_manifests.count.must_equal 0
end
end
end

describe "duplicated frameworks" do
Expand Down Expand Up @@ -49,6 +60,17 @@
assert_successful_command "#{ __dir__ }/../fixtures/bookshelf/config/environment.rb"
assert_successful_output(assets)
end

describe "when already precompiled " do
it "cleans up the destination directory before to precompile" do
2.times do
assert_successful_command "#{ __dir__ }/../fixtures/bookshelf/config/environment.rb"
end

duplicated_manifests = Dir[dest.join('assets-*.json').to_s]
duplicated_manifests.count.must_equal 0
end
end
end

describe "when 'config' is omitted" do
Expand Down

0 comments on commit e18fa83

Please sign in to comment.