Sha256: 09dd02c3fe1a220690145fe586a26698ec541f1af1f44644bc62c046827325f3

Contents?: true

Size: 813 Bytes

Versions: 16

Compression:

Stored size: 813 Bytes

Contents

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

16 entries across 16 versions & 1 rubygems

Version Path
opal-1.7.4 stdlib/nodejs/fileutils.rb
opal-1.7.3 stdlib/nodejs/fileutils.rb
opal-1.7.2 stdlib/nodejs/fileutils.rb
opal-1.7.1 stdlib/nodejs/fileutils.rb
opal-1.7.0 stdlib/nodejs/fileutils.rb
opal-1.7.0.rc1 stdlib/nodejs/fileutils.rb
opal-1.6.1 stdlib/nodejs/fileutils.rb
opal-1.6.0 stdlib/nodejs/fileutils.rb
opal-1.6.0.rc1 stdlib/nodejs/fileutils.rb
opal-1.6.0.alpha1 stdlib/nodejs/fileutils.rb
opal-1.5.1 stdlib/nodejs/fileutils.rb
opal-1.5.0 stdlib/nodejs/fileutils.rb
opal-1.5.0.rc1 stdlib/nodejs/fileutils.rb
opal-1.4.1 stdlib/nodejs/fileutils.rb
opal-1.4.0 stdlib/nodejs/fileutils.rb
opal-1.4.0.alpha1 stdlib/nodejs/fileutils.rb