Skip to content

Commit 8750853

Browse files
committed
Clean old sourcemap assets
1 parent fb52297 commit 8750853

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lib/propshaft/output_path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def all_files_from_tree(path)
5353
end
5454

5555
def extract_path_and_digest(digested_path)
56-
digest = digested_path.to_s[/-([0-9a-f]{7,128})\.(?!digested)[^.]+\z/, 1]
56+
digest = digested_path.to_s[/-([0-9a-f]{7,128})\.(?!digested)/, 1]
5757
path = digest ? digested_path.sub("-#{digest}", "") : digested_path
5858

5959
[path, digest]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
One from first path map

test/propshaft/output_path_test.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class Propshaft::OutputPathTest < ActiveSupport::TestCase
88
setup do
99
@manifest = {
1010
".manifest.json": ".manifest.json",
11-
"one.txt": "one-f2e1ec14.txt"
11+
"one.txt": "one-f2e1ec14.txt",
12+
"one.txt.map": "one-f2e1ec15.txt.map"
1213
}.stringify_keys
1314
@output_path = Propshaft::OutputPath.new(Pathname.new("#{__dir__}/../fixtures/output"), @manifest)
1415
end
@@ -49,6 +50,19 @@ class Propshaft::OutputPathTest < ActiveSupport::TestCase
4950
FileUtils.rm(current) if File.exist?(current)
5051
end
5152

53+
test "clean keeps the correct number of versions regardless of the file extension" do
54+
old = output_asset("by_count.txt.map", "old", created_at: Time.now - 300)
55+
current = output_asset("by_count.txt.map", "current", created_at: Time.now - 180)
56+
57+
@output_path.clean(1, 0)
58+
59+
assert File.exist?(current)
60+
assert_not File.exist?(old)
61+
ensure
62+
FileUtils.rm(old) if File.exist?(old)
63+
FileUtils.rm(current) if File.exist?(current)
64+
end
65+
5266
test "clean keeps all versions under a certain age" do
5367
old = output_asset("by_age.txt", "old")
5468
current = output_asset("by_age.txt", "current")

0 commit comments

Comments
 (0)