Sha256: 6e74012414217d6f68d034eaf6d5951bc3cd9763c3b708bbd9f7f0df3f1bb9e4

Contents?: true

Size: 842 Bytes

Versions: 6

Compression:

Stored size: 842 Bytes

Contents

# backtick_javascript: true

module FileUtils
  extend self
  `var __fs__ = #{File}.__fs__`

  def chmod(mode, file_list)
    raise NotImplementedError, 'symbolic mode is not supported, use numeric mode' if String === mode
    Array(file_list).each do |file|
      `__fs__.chmodSync(mode, file)`
    end
  end

  def cp(source, target)
    target = File.join(target, File.basename(source)) if File.directory? target
    `__fs__.writeFileSync(target, __fs__.readFileSync(source))`
  end

  def rm(path)
    `__fs__.unlinkSync(path)`
  end

  def mkdir_p(path)
    return true if File.directory? path
    `__fs__.mkdirSync(#{path})`
  end

  def mv(source, target)
    target = File.join(target, File.basename(source)) if File.directory? target
    `__fs__.renameSync(source, target)`
  end

  alias mkpath mkdir_p
  alias makedirs mkdir_p
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 stdlib/nodejs/fileutils.rb
opal-1.8.2 stdlib/nodejs/fileutils.rb
opal-1.8.1 stdlib/nodejs/fileutils.rb
opal-1.8.0 stdlib/nodejs/fileutils.rb
opal-1.8.0.beta1 stdlib/nodejs/fileutils.rb
opal-1.8.0.alpha1 stdlib/nodejs/fileutils.rb