Skip to content

Commit

Permalink
fix sourcepath directory expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Aug 31, 2018
1 parent b06fa68 commit e41304c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/simplygenius/atmos/source_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def expand_location
g = Git.clone(sourcepath, 'atmos-checkout', depth: 1, path: tmpdir)
local_template_path = File.join(g.dir.path, template_subdir)

sourcepath_dir = local_template_path
logger.debug("Using git sourcepath: #{local_template_path}")
sourcepath_dir = File.expand_path(local_template_path)
logger.debug("Using git sourcepath: #{sourcepath_dir}")
rescue => e
msg = "Could not read from git archive, ignoring sourcepath: #{name}, #{location}"
logger.log_exception(e, msg, level: :debug)
Expand All @@ -123,8 +123,8 @@ def expand_location
end

local_template_path = File.join(tmpdir, template_subdir)
sourcepath_dir = local_template_path
logger.debug("Using zip sourcepath: #{local_template_path}")
sourcepath_dir = File.expand_path(local_template_path)
logger.debug("Using zip sourcepath: #{sourcepath_dir}")
rescue => e
msg = "Could not read from zip archive, ignoring sourcepath: #{name}, #{location}"
logger.log_exception(e, msg, level: :debug)
Expand All @@ -135,8 +135,8 @@ def expand_location

else

logger.debug("Using local sourcepath: #{sourcepath}")
sourcepath_dir = File.expand_path(sourcepath)
logger.debug("Using local sourcepath: #{sourcepath_dir}")

end

Expand All @@ -145,7 +145,6 @@ def expand_location

def template_dirs
@template_dirs ||= begin
directory = expand_location
template_dirs = {}
if directory && Dir.exist?(directory)

Expand Down
6 changes: 4 additions & 2 deletions spec/source_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def git_repo_fixture
expanded = described_class.new("test", repo_dir)
expect(expanded.directory).to match(/^\/.*/)
expect(Dir.exist?(expanded.directory)).to be true
expect(expanded.template_dir('template1')).to start_with(expanded.directory)
end

it "uses subdir from a git archive" do
Expand Down Expand Up @@ -248,10 +249,11 @@ def git_repo_fixture
end

it "uses subdir from a zip archive" do
expanded = described_class.new("test", "#{fixture_dir}/template_repo.zip#template_repo/subdir")
expanded = described_class.new("test", "#{fixture_dir}/template_repo.zip#template_repo")
expect(expanded.directory).to match(/^\/.*/)
expect(expanded.directory).to match(/template_repo\/subdir$/)
expect(expanded.directory).to match(/template_repo$/)
expect(Dir.exist?(expanded.directory)).to be true
expect(expanded.template_dir('template1')).to start_with(expanded.directory)
end

end
Expand Down

0 comments on commit e41304c

Please sign in to comment.