Can mix project elixirc_paths accept regex?

Hi,

I want to forbid parsing/compiling of files ending with "_tmp.ex". I have seen in mix.exs, def project, the key "elixirc_paths" but it accepts a list of strings.

Can I set regex?

Can I set negative paths to remove from the compiling paths?

Eg. ["lib", "!lib/something"] will compile all in libs but lib/something.
Eg. ["lib", r~/!.*_tmp\.ex/] will compile all in libs but not files ending with _tmp.ex

If the answer is no, how can I achieve what I want? My use case is when I what to try fast modifications and I clone the file temporarily in the same path, then it should be avoided from compiling. I prefer to avoid changing the original file, because I know I can change the elixir module name and It won’t complain.

@trashyEx: I don’t recommend adding temporary files to lib directory. Instead of I suggest you to move them to for example: priv/lib_tmp and then run them with command: mix run priv/lib_tmp/my_file.ex. Of course you should also add priv/lib_tmp to .gitignore file to avoid mistakes.

To answer your question:

  1. By default mix extract files using &Path.wildcard/2
  2. You could manually create a function that returns list of valid files that matches specified regular expression.

Personally, I rely on git for these things. Git branch is so fast and cheap that its great for little experiments, and for really fast / trivial changes, changing in-line is fine as git allows you to very easily and quickly back out changes to files. Unless you have some special need, I would recommend looking at your revision control program for help in these situations.

2 Likes

Especially this. If you don’t have a few dozen branches in your projects then you are probably doing something quite wrong.

Well, at least I try to keep those experimental branches local and only push the actual WIP feature-branch.

1 Like