Skip to content

Commit

Permalink
fix renaming provided files to a parent directory when omitting the f…
Browse files Browse the repository at this point in the history
…ilename

expand_path would strip the leading ../

The new behavior keeps leading ./, however this was already the case when doing "file > ./foo".
  • Loading branch information
cfillion committed Apr 7, 2024
1 parent b35bd2a commit 06541f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/reapack/index/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ def parse_provides(provides)
files.map {|file|
if line.target
if line.target =~ /[\/\\\.]+\z/
new_dir = ReaPack::Index.expand line.target, ''
base_file = File.basename file
target = new_dir.empty? ? base_file : File.join(new_dir, base_file)
target = File.join line.target, base_file
else
target = line.target
end
Expand Down
9 changes: 6 additions & 3 deletions test/index/test_provides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,9 @@ def test_rename_target
@version 1.0
@provides
source.lua > target.lua
source.png > target.png
source.png > ./target.png
source*.jpg > target_dir/
source*.jpg > ../target_dir/
sub/source.txt > .
IN

Expand All @@ -382,10 +383,12 @@ def test_rename_target
xml = File.read index.path

assert_match 'file="target.lua"', xml
assert_match 'file="target.png"', xml
assert_match 'file="./target.png"', xml
assert_match 'file="target_dir/source1.jpg"', xml
assert_match 'file="target_dir/source2.jpg"', xml
assert_match 'file="source.txt"', xml
assert_match 'file="../target_dir/source1.jpg"', xml
assert_match 'file="../target_dir/source2.jpg"', xml
assert_match 'file="./source.txt"', xml
refute_match 'file="source.png"', xml

assert_equal 1,
Expand Down

0 comments on commit 06541f6

Please sign in to comment.