mirror of
https://github.com/sloanelybutsurely/typeid-elixir.git
synced 2025-05-18 11:12:53 -04:00
replace shell script with elixir script
This commit is contained in:
parent
f0e24c7231
commit
6232bf4c7f
2 changed files with 27 additions and 4 deletions
scripts
27
scripts/update_spec
Executable file
27
scripts/update_spec
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env -S ERL_FLAGS=+B elixir
|
||||
|
||||
Mix.install(req: "~> 0.4")
|
||||
|
||||
files = [
|
||||
{"https://raw.githubusercontent.com/jetpack-io/typeid/main/spec/invalid.yml", "priv/spec/invalid.yml"},
|
||||
{"https://raw.githubusercontent.com/jetpack-io/typeid/main/spec/valid.yml", "priv/spec/valid.yml"}
|
||||
]
|
||||
|
||||
IO.puts("Updating spec YAML files")
|
||||
|
||||
:ok = for {src, dest} <- files, reduce: :ok do
|
||||
:ok ->
|
||||
IO.write("Downloading #{src} to #{dest}... ")
|
||||
with {:ok, io} <- File.open(dest, [:write]),
|
||||
{:ok, _} <- Req.get(src, into: IO.binstream(io, 500)) do
|
||||
IO.puts("OK")
|
||||
:ok
|
||||
else
|
||||
other ->
|
||||
IO.puts("ERROR")
|
||||
other
|
||||
end
|
||||
failure -> failure
|
||||
end
|
||||
|
||||
IO.puts("Done!")
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env bash -ex
|
||||
|
||||
wget https://raw.githubusercontent.com/jetpack-io/typeid/main/spec/invalid.yml -O priv/spec/invalid.yml
|
||||
wget https://raw.githubusercontent.com/jetpack-io/typeid/main/spec/valid.yml -O priv/spec/valid.yml
|
Loading…
Reference in a new issue