@@ -300,33 +300,31 @@ defmodule Mix.Utils do
300300 """
301301 def symlink_or_copy ( source , target ) do
302302 if File . exists? ( source ) do
303- source_list = String . to_char_list ( source )
303+ # Relative symbolic links on windows are broken
304+ link = case :os . type do
305+ { :win32 , _ } -> source
306+ _ -> make_relative_path ( source , target )
307+ end |> String . to_char_list
308+
304309 case :file . read_link ( target ) do
305- { :ok , ^ source_list } ->
310+ { :ok , ^ link } ->
306311 :ok
307312 { :ok , _ } ->
308313 File . rm! ( target )
309- do_symlink_or_copy ( source , target )
314+ do_symlink_or_copy ( source , target , link )
310315 { :error , :enoent } ->
311- do_symlink_or_copy ( source , target )
316+ do_symlink_or_copy ( source , target , link )
312317 { :error , _ } ->
313318 _ = File . rm_rf! ( target )
314- do_symlink_or_copy ( source , target )
319+ do_symlink_or_copy ( source , target , link )
315320 end
316321 else
317322 { :error , :enoent }
318323 end
319324 end
320325
321- defp do_symlink_or_copy ( source , target ) do
322-
323- # relative symbolic links on windows are broken
324- source_path = case :os . type do
325- { :win32 , _ } -> source
326- _ -> make_relative_path ( source , target )
327- end
328-
329- case :file . make_symlink ( source_path , target ) do
326+ defp do_symlink_or_copy ( source , target , link ) do
327+ case :file . make_symlink ( link , target ) do
330328 :ok -> :ok
331329 { :error , _ } -> { :ok , File . cp_r! ( source , target ) }
332330 end
0 commit comments