addEntriesToLegacyOutputArray

in tools/convert-shared-credential-to-legacy-format.rb [14:33]


def addEntriesToLegacyOutputArray(file_path, legacy_output_array)
  file_contents = File.read file_path
  contents_as_object = JSON.parse file_contents

  contents_as_object.each do |dictionary|
    array_to_push_to_legacy_output_array = []
    if dictionary["shared"]
      array_to_push_to_legacy_output_array = dictionary["shared"]
    elsif dictionary["from"] and dictionary["to"]
      array_to_push_to_legacy_output_array = dictionary["from"].concat dictionary["to"]
    end

    if array_to_push_to_legacy_output_array.length > 0
      legacy_output_array.push array_to_push_to_legacy_output_array
    else
      STDERR.puts "ERROR: There was an entry in #{file_path} that couldn't be put into the legacy format."
    end
  end
end