Module: FileUtils

Extended by:
FFI::Library
Defined in:
lib/buildr/core/util.rb,
lib/buildr/core/util.rb

Overview

Fix for BUILDR-292. JRuby fails to rename a file on different devices this monkey-patch wont be needed when JRUBY-3381 gets resolved.

Instance Method Summary collapse

Instance Method Details

#__mv_nativeObject

:nodoc:



321
# File 'lib/buildr/core/util.rb', line 321

alias_method :__mv_native, :mv

#sh(*cmd, &block) ⇒ Object

code “borrowed” directly from Rake



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/buildr/core/util.rb', line 415

def sh(*cmd, &block)
  options = (Hash === cmd.last) ? cmd.pop : {}
  unless block_given?
    show_command = cmd.join(" ")
    show_command = show_command[0,42] + "..."
    
    block = lambda { |ok, status|
      ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
    }
  end
  if RakeFileUtils.verbose_flag == :default
    options[:verbose] = false
  else
    options[:verbose] ||= RakeFileUtils.verbose_flag
  end
  options[:noop]    ||= RakeFileUtils.nowrite_flag
  rake_check_options options, :noop, :verbose
  rake_output_message cmd.join(" ") if options[:verbose]
  unless options[:noop]
    cd = "cd '#{Dir.pwd}' && "
    args = if cmd.size > 1 then cmd[1..cmd.size] else [] end
    
    res = if Buildr::Util.win_os? && cmd.size == 1
      __native_system__("#{cd} call #{cmd.first}")
    else
      arg_str = args.map { |a| "'#{a}'" }
      __native_system__(cd + cmd.first + ' ' + arg_str.join(' '))
    end
    $? = Buildr::ProcessStatus.new(0, res == 0, res)    # KLUDGE
    block.call(res == 0, $?)
  end
end