How To Get The Root Directory Of an Elixir Project

2020-08-09 10:34发布

问题:

In an Elixir project, you can use

Path.expand

to define a file or directory as a relative path from the current file.

For example: Path.expand("../../../lib/file.ex")

but how about finding a path from the root level of the project?

回答1:

If you'd like to get the project's root directory, use

File.cwd!

source: https://groups.google.com/d/topic/elixir-lang-talk/Ls0eJDdMMW8

(note: I pulled this here only so it's not buried in a dead forum behind Google auth wall & subject to Google data preservation policies)



标签: elixir