lib/travis/cli/encrypt.rb in travis-1.1.3 vs lib/travis/cli/encrypt.rb in travis-1.2.0

- old
+ new

@@ -31,15 +31,17 @@ data = split? ? data.split("\n") : [data] encrypted = data.map { |data| repository.encrypt(data) } if config_key travis_config = YAML.load_file(travis_yaml) + travis_config = {} if [[], false, nil].include? travis_config keys = config_key.split('.') last_key = keys.pop nested_config = keys.inject(travis_config) { |c,k| c[k] ||= {}} + nested_config = nested_config[last_key] ||= [] encrypted.each do |encrypted| - nested_config[last_key] ||= [] << { 'secure' => encrypted } + nested_config << { 'secure' => encrypted } end File.write(travis_yaml, travis_config.to_yaml) else list = encrypted.map { |data| format(data.inspect, " secure: %s") } say(list.join("\n"), template(__FILE__), :none) @@ -52,10 +54,11 @@ path = File.expand_path('.travis.yml', dir) if File.exist? path path else parent = File.expand_path('..', dir) - travis_yaml(parent) if parent != dir + error "no .travis.yml found" if parent == dir + travis_yaml(parent) end end end end end