Skip to content

Commit

Permalink
Fix project selection when using project_dir config
Browse files Browse the repository at this point in the history
  • Loading branch information
greeneca committed Feb 3, 2017
1 parent 5849e01 commit 02f2985
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
@@ -1,3 +1,7 @@
= 3.12.1 =

- Fix project selection when using the project_dir config value

= 3.12.0 =

- Add optional "parent_config", "project_dir", and "key_dir" config options
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
roku_builder (3.12.0)
roku_builder (3.12.1)
faraday (~> 0.11)
faraday-digestauth (~> 0.2)
git (~> 1.3)
Expand Down
7 changes: 6 additions & 1 deletion lib/roku_builder/config_parser.rb
Expand Up @@ -47,7 +47,12 @@ def self.setup_project(config:, options:)
project = nil
config[:projects].each_pair {|key,value|
if value.is_a?(Hash)
repo_path = Pathname.new(value[:directory]).realdirpath
repo_path = ""
if config[:projects][:project_dir]
repo_path = Pathname.new(File.join(config[:projects][:project_dir], value[:directory])).realdirpath
else
repo_path = Pathname.new(value[:directory]).realdirpath
end
path.descend do |path_parent|
if path_parent == repo_path
project = key
Expand Down
2 changes: 1 addition & 1 deletion lib/roku_builder/version.rb
Expand Up @@ -2,5 +2,5 @@

module RokuBuilder
# Version of the RokuBuilder Gem
VERSION = "3.12.0"
VERSION = "3.12.1"
end
26 changes: 26 additions & 0 deletions test/roku_builder/test_config_parser.rb
Expand Up @@ -82,6 +82,7 @@ def test_manifest_config_project_directory
config = good_config
config[:projects][:project_dir] = "/tmp"
config[:projects][:project1][:directory] = "project1"
config[:projects][:project2][:directory] = "project2"


code = nil
Expand All @@ -94,6 +95,31 @@ def test_manifest_config_project_directory
assert_equal "/tmp/project1", configs[:project_config][:directory]
end

def test_manifest_config_project_select
logger = Logger.new("/dev/null")
options = {
config: File.expand_path(File.join(File.dirname(__FILE__), "test_files", "controller_config_test", "valid_config.json")),
stage: 'production',
update_manifest: false,
fetch: false,
}
config = good_config
config[:projects][:project_dir] = "/tmp"
config[:projects][:project1][:directory] = "project1"
config[:projects][:project2][:directory] = "project2"

code = nil
configs = nil

Pathname.stub(:pwd, Pathname.new("/tmp/project2")) do
code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
end

assert_equal RokuBuilder::SUCCESS, code
assert_equal Hash, config.class
assert_equal "/tmp/project2", configs[:project_config][:directory]
end

def test_manifest_config_key_directory
logger = Logger.new("/dev/null")
options = {key: true, project: :project2}
Expand Down

0 comments on commit 02f2985

Please sign in to comment.