Skip to content

Commit b5febd9

Browse files
author
José Valim
committed
Allow elixirc_paths to also be given through the command line
Once given, the command line overrides the project configuration in `mix compile.elixir`. Closes #2557
1 parent f1323ad commit b5febd9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [Map] Add `Map.from_struct/1`
1010
* [Mix] Allow `--app` flag to be passed to `mix new`
1111
* [Mix] Support lowercase `http(s)_proxy` environment variables
12+
* [Mix] Allow `elixirc_paths` to also be given through the command line to `mix compile.elixir`
1213
* [String] `String.slice/2` and `String.slice/3` have been optimized
1314

1415
* Bug fixes
@@ -17,7 +18,7 @@
1718
* [Kernel] Correctly parse unary/binary operators regardless of number of spaces
1819
* [Kernel] Ensure private functions are not exported
1920
* [Protocol] Do not expose protocol convention on `assert_impl!/2`
20-
* [Regex] Do not consider subpatterns on `Regex.split/3`
21+
* [Regex] Do not consider include captures on `Regex.split/3` results
2122
* [Stream] Implement the `Inspect` protocol for Streams so we do not leak the Stream representation
2223

2324
* Deprecations
@@ -34,6 +35,7 @@
3435

3536
* Backwards incompatible changes
3637
* [Kernel] `binding/1` and `binding/2` expecting a list were removed
38+
* [Regex] Do not consider include captures on `Regex.split/3` results
3739

3840
## v0.14.3 (2014-07-12)
3941

lib/mix/lib/mix/tasks/compile.elixir.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ defmodule Mix.Tasks.Compile.Elixir do
2222
* `--debug-info` (`--no-debug-info`) - attach (or not) debug info to compiled modules
2323
* `--ignore-module-conflict` - do not emit warnings if a module was previously defined
2424
* `--warnings-as-errors` - treat warnings as errors and return a non-zero exit code
25+
* `--elixirc-paths` - paths to lookup for Elixir source.
26+
Can be given multiple times and, once given, overrides the project elixirc_paths config.
2527
2628
## Configuration
2729
@@ -37,7 +39,8 @@ defmodule Mix.Tasks.Compile.Elixir do
3739
"""
3840

3941
@switches [force: :boolean, docs: :boolean, warnings_as_errors: :boolean,
40-
ignore_module_conflict: :boolean, debug_info: :boolean]
42+
ignore_module_conflict: :boolean, debug_info: :boolean,
43+
elixirc_paths: :keep]
4144

4245
@doc """
4346
Runs this task.
@@ -46,8 +49,11 @@ defmodule Mix.Tasks.Compile.Elixir do
4649
{opts, _, _} = OptionParser.parse(args, switches: @switches)
4750

4851
project = Mix.Project.config
49-
srcs = project[:elixirc_paths]
5052
dest = Mix.Project.compile_path(project)
53+
srcs = case Keyword.get_values(opts, :elixirc_paths) do
54+
[] -> project[:elixirc_paths]
55+
ep -> ep
56+
end
5157

5258
manifest = manifest()
5359
configs = Mix.Project.config_files ++ Mix.Tasks.Compile.Erlang.manifests

lib/mix/test/mix/tasks/compile.elixir_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ defmodule Mix.Tasks.Compile.ElixirTest do
180180
# Nothing to compile with the custom source paths
181181
assert Mix.Tasks.Compile.Elixir.run([])
182182
refute_received {:mix_shell, :info, ["Compiled lib/a.ex"]}
183+
184+
assert Mix.Tasks.Compile.Elixir.run(["--elixirc-paths", "lib"])
185+
assert_received {:mix_shell, :info, ["Compiled lib/a.ex"]}
183186
end
184187
end
185188
end

0 commit comments

Comments
 (0)