File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,19 @@ defmodule Mix.Tasks.Cmd do
75
75
end
76
76
77
77
if apps == [ ] or Mix.Project . config ( ) [ :app ] in apps do
78
+ path = hd ( args )
79
+ rest = tl ( args )
80
+
81
+ path =
82
+ if String . contains? ( path , [ "/" , "\\ " ] ) and Path . type ( path ) != :absolute do
83
+ Path . expand ( path , Keyword . get ( opts , :cd , "." ) )
84
+ else
85
+ path
86
+ end
87
+
78
88
cmd_opts = Keyword . take ( opts , [ :cd ] )
79
89
80
- case Mix . shell ( ) . cmd ( { hd ( args ) , tl ( args ) } , cmd_opts ) do
90
+ case Mix . shell ( ) . cmd ( { path , rest } , cmd_opts ) do
81
91
0 -> :ok
82
92
status -> exit ( status )
83
93
end
Original file line number Diff line number Diff line change @@ -14,6 +14,21 @@ defmodule Mix.Tasks.CmdTest do
14
14
assert_received { :mix_shell , :run , [ "hello world\n " ] }
15
15
end
16
16
17
+ @ tag :unix
18
+ test "supports relative paths" do
19
+ in_tmp ( "cmd-relative" , fn ->
20
+ File . mkdir_p! ( "priv" )
21
+ File . write! ( "priv/world.sh" , "#!/bin/sh\n echo world" )
22
+ File . chmod! ( "priv/world.sh" , 0o755 )
23
+
24
+ Mix.Task . run ( "cmd" , [ "priv/world.sh" ] )
25
+ assert_received { :mix_shell , :run , [ "world\n " ] }
26
+
27
+ Mix.Task . run ( "cmd" , [ "--cd" , "priv" , "./world.sh" ] )
28
+ assert_received { :mix_shell , :run , [ "world\n " ] }
29
+ end )
30
+ end
31
+
17
32
test "runs the command for each app" do
18
33
in_fixture ( "umbrella_dep/deps/umbrella" , fn ->
19
34
Mix.Project . in_project ( :umbrella , "." , fn _ ->
You can’t perform that action at this time.
0 commit comments