Skip to content

Commit da0fd6c

Browse files
committed
fix: replace :code.priv_dir/1 function
1 parent 5c33d7f commit da0fd6c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/tasks/gen/migration.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule Mix.Tasks.Mongo.Gen.Migration do
1212

1313
@spec run([String.t()]) :: integer()
1414
def run(args) do
15-
migrations_path = Migration.migration_file_path()
15+
migrations_path = migration_file_path()
1616
name = List.first(args)
1717
base_name = "#{underscore(name)}.exs"
1818
current_timestamp = timestamp()
@@ -29,6 +29,15 @@ defmodule Mix.Tasks.Mongo.Gen.Migration do
2929
String.to_integer(current_timestamp)
3030
end
3131

32+
@doc """
33+
Returns the private repository path relative to the source.
34+
"""
35+
def migration_file_path() do
36+
path = "priv/" <> Migration.get_config()[:path]
37+
otp_app = Migration.get_config()[:otp_app]
38+
Path.join(Mix.Project.deps_paths()[otp_app] || File.cwd!(), path)
39+
end
40+
3241
defp timestamp do
3342
{{y, m, d}, {hh, mm, ss}} = :calendar.universal_time()
3443
"#{y}#{pad(m)}#{pad(d)}#{pad(hh)}#{pad(mm)}#{pad(ss)}"

0 commit comments

Comments
 (0)