Skip to content

Commit e40e9a8

Browse files
authored
Allow --no-compile/--no-check-deps to "mix sentry.package_source_code" (#776)
This is useful when building releases using alternative tools. For example, this is important with `nix`, where dependencies are fetched, compiled and symlinked without going through `mix`.
1 parent 69ac8d0 commit e40e9a8

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

lib/mix/tasks/sentry.package_source_code.ex

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ defmodule Mix.Tasks.Sentry.PackageSourceCode do
5555
`priv` directory is read-only, such as with [NixOS](https://github.com/NixOS/nixpkgs)
5656
and similar tools.
5757
*Available since v10.2.0*.
58+
* `--no-compile` - does not compile applications before running
59+
* `--no-deps-check` - does not check dependencies before running
5860
5961
"""
6062

@@ -68,22 +70,28 @@ defmodule Mix.Tasks.Sentry.PackageSourceCode do
6870
@bytes_in_mb 1024 * 1024
6971
@bytes_in_gb 1024 * 1024 * 1024
7072

71-
# Don't call the app.config task here, see
72-
# https://github.com/getsentry/sentry-elixir/commit/b2a04ddcf5d5c5f861da9888b3dec2f4f12cee01
73-
@requirements [
74-
"loadpaths",
75-
"compile"
76-
]
77-
7873
@switches [
7974
debug: :boolean,
80-
output: :string
75+
output: :string,
76+
no_compile: :boolean,
77+
no_deps_check: :boolean
8178
]
8279

8380
@impl true
8481
def run(args) do
8582
{opts, _args} = OptionParser.parse!(args, strict: @switches)
8683

84+
# Don't call the app.config task here, see
85+
# https://github.com/getsentry/sentry-elixir/commit/b2a04ddcf5d5c5f861da9888b3dec2f4f12cee01
86+
87+
if not Keyword.get(opts, :no_deps_check, false) do
88+
Mix.Task.run("loadpaths")
89+
end
90+
91+
if not Keyword.get(opts, :no_compile, false) do
92+
Mix.Task.run("compile")
93+
end
94+
8795
config = Application.get_all_env(:sentry)
8896

8997
{elapsed, source_map} =

test/mix/sentry.package_source_code_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ defmodule Mix.Tasks.Sentry.PackageSourceCodeTest do
7575
assert :ok = Mix.Task.rerun("sentry.package_source_code")
7676
end
7777

78+
test "supports --no-compile and --no-deps-check" do
79+
assert :ok = Mix.Task.rerun("sentry.package_source_code", ["--no-compile", "--no-deps-check"])
80+
end
81+
7882
defp validate_map_file!(path) do
7983
assert_receive {:mix_shell, :info, ["Wrote " <> _ = message]}
8084
assert message =~ path

0 commit comments

Comments
 (0)