Skip to content

Commit

Permalink
Don't require Rust tooling to update the default blocklist
Browse files Browse the repository at this point in the history
The JSON output was there all along. That was silly of me!
  • Loading branch information
g-andrade committed Oct 14, 2023
1 parent 6cf55e1 commit 950182a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
1 change: 0 additions & 1 deletion blocklist/canonical.json

This file was deleted.

31 changes: 3 additions & 28 deletions blocklist/update.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ defmodule Sqids.BlocklistUpdater do

require Logger

@canonical_path "blocklist/canonical.json"
@canonical_path "deps/sqids_blocklist/output/blocklist.json"
@one_word_per_line_path "blocklist/one_word_per_line.txt"

def run do
install_script_deps()
update_blocklist_repo()
generate_canonical_list()
convert_from_canonical_list()
end

Expand All @@ -27,19 +26,6 @@ defmodule Sqids.BlocklistUpdater do
:ok = run_cmd(~w(mix deps.update sqids_blocklist))
end

defp generate_canonical_list do
log_step("Generating canonical list...")

file = File.stream!(@canonical_path)

:ok =
run_cmd(
~w(cargo run),
cd: "deps/sqids_blocklist",
into: file
)
end

defp convert_from_canonical_list do
log_step("Converting canonical blocklist...")

Expand All @@ -63,19 +49,8 @@ defmodule Sqids.BlocklistUpdater do
end)
end

defp run_cmd([cmd | args], opts \\ []) when is_list(args) do
cd = opts[:cd]
into = opts[:into] || IO.stream(:stderr, :line)
stderr_to_stdout = !opts[:into]

cmd_opts = [into: into, stderr_to_stdout: stderr_to_stdout]

cmd_opts =
if cd do
cmd_opts ++ [cd: cd]
else
cmd_opts
end
defp run_cmd([cmd | args]) do
cmd_opts = [stderr_to_stdout: true]

case System.cmd(cmd, args, cmd_opts) do
{_, 0} ->
Expand Down

0 comments on commit 950182a

Please sign in to comment.