Module: FileUtils
- Extended by:
- FFI::Library
- Defined in:
- lib/buildr/core/application.rb,
lib/buildr/core/util.rb,
lib/buildr/core/util.rb,
lib/buildr/core/application.rb
Overview
Under windows, paths passed to mkpath, mkdir_p and mkdirs need to be normalized. Otherwise ruby may decide to treat the drive component as a directory (i.e. create a directory named “C:”). This patch hooks in at a low level to work around this issue.
Instance Method Summary collapse
-
#fu_list(arg) ⇒ Object
:nodoc:.
-
#sh(*cmd, &block) ⇒ Object
code “borrowed” directly from Rake.
Instance Method Details
#fu_list(arg) ⇒ Object
:nodoc:
675 676 677 |
# File 'lib/buildr/core/application.rb', line 675 def fu_list(arg) #:nodoc: [arg].flatten.map { |path| Buildr::Util.normalize_path(path) } end |
#sh(*cmd, &block) ⇒ Object
code “borrowed” directly from Rake
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/buildr/core/util.rb', line 362 def sh(*cmd, &block) = (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 == Rake::FileUtilsExt::DEFAULT [:verbose] = false else [:verbose] ||= RakeFileUtils.verbose_flag end [:noop] ||= RakeFileUtils.nowrite_flag , :noop, :verbose cmd.join(" ") if [:verbose] unless [:noop] if Buildr::Util.win_os? # Ruby uses forward slashes regardless of platform, # unfortunately cd c:/some/path fails on Windows pwd = Dir.pwd.gsub(%r{/}, '\\') cd = "cd /d \"#{pwd}\" && " else cd = "cd '#{Dir.pwd}' && " end 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 status = Buildr::ProcessStatus.new(0, res == 0, res) # KLUDGE block.call(res == 0, status) end end |