Skip to content

Commit

Permalink
Allow absolute defined paths
Browse files Browse the repository at this point in the history
  • Loading branch information
greeneca committed Apr 19, 2018
1 parent 10f3abf commit 3f9eb94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/roku_builder/config_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def is_current_project?(project_config:)
end

def get_repo_path(project_config:)
if @config[:projects][:project_dir]
if @config[:projects][:project_dir] and !Pathname.new(project_config[:directory]).absolute?
Pathname.new(File.join(@config[:projects][:project_dir], project_config[:directory])).realdirpath
else
Pathname.new(project_config[:directory]).realdirpath
Expand Down Expand Up @@ -137,7 +137,7 @@ def stub_project_config_for_current
end

def set_project_directory
if @config[:projects][:project_dir]
if @config[:projects][:project_dir] and !Pathname.new(@parsed[:project][:directory]).absolute?
@parsed[:project][:directory] = File.join(@config[:projects][:project_dir], @parsed[:project][:directory])
end
unless Dir.exist?(@parsed[:project][:directory])
Expand Down
18 changes: 18 additions & 0 deletions test/roku_builder/test_config_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ def test_manifest_config_project_directory_select
assert_equal "/tmp/project2", configs[:project][:directory]
end

def test_manifest_config_project_directory_select
options = build_options({validate: true, working: true})
options.define_singleton_method(:source_commands){[:validate]}
config = good_config(ConfigParserTest)
config[:projects][:project_dir] = "/tmp"
config[:projects][:project1][:directory] = "/tmp/project1"

configs = nil
Pathname.stub(:pwd, Pathname.new("/tmp/project1")) do
Dir.stub(:exist?, true) do
configs = ConfigParser.parse(options: options, config: config)
end
end

assert_equal Hash, config.class
assert_equal "/tmp/project1", configs[:project][:directory]
end

def test_key_config_key_directory
tmp_file = Tempfile.new("pkg")
options = build_options({validate: true, project: :project2, stage: 'production'})
Expand Down

0 comments on commit 3f9eb94

Please sign in to comment.