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
7575 end
7676
7777 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+
7888 cmd_opts = Keyword . take ( opts , [ :cd ] )
7989
80- case Mix . shell ( ) . cmd ( { hd ( args ) , tl ( args ) } , cmd_opts ) do
90+ case Mix . shell ( ) . cmd ( { path , rest } , cmd_opts ) do
8191 0 -> :ok
8292 status -> exit ( status )
8393 end
Original file line number Diff line number Diff line change @@ -14,6 +14,21 @@ defmodule Mix.Tasks.CmdTest do
1414 assert_received { :mix_shell , :run , [ "hello world\n " ] }
1515 end
1616
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+
1732 test "runs the command for each app" do
1833 in_fixture ( "umbrella_dep/deps/umbrella" , fn ->
1934 Mix.Project . in_project ( :umbrella , "." , fn _ ->
You can’t perform that action at this time.
0 commit comments