Skip to content

Commit

Permalink
File.cd!("deps/quotes", File.read!("quotes.json"))
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Mar 26, 2020
1 parent aabf2a8 commit cc6b817
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/quotes.ex
Expand Up @@ -30,20 +30,16 @@ defmodule Quotes do
"""
def parse_json do
{:ok, cwd} = File.cwd
# IO.inspect(cwd, label: "cwd")
# we need this cd in order to locate the file in deps
# coveralls-ignore-start
cwd = case cwd =~ "/quotes" do
# we need this cd to locate the file in /deps
case cwd =~ "/quotes" do
# coveralls-ignore-start
true ->
cwd
false ->
File.cd!("deps/quotes")
{:ok, cwd} = File.cwd
cwd
File.read!(cwd <> "/quotes.json") |> Jason.decode!()
false -> # temporarily cd into deps/quotes dir and read quotes.json file:
File.cd!("deps/quotes", File.read!("quotes.json"))
|> Jason.decode!(data)
# coveralls-ignore-stop
end
# coveralls-ignore-stop
IO.inspect(cwd, label: "cwd")
File.read!(cwd <> "/quotes.json") |> Jason.decode!()
end

@doc """
Expand Down

0 comments on commit cc6b817

Please sign in to comment.