Sha256: 543501ef104f607edaa91391a1e6b8359d63d683f677decfa0fb0a4e90a1af66

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

require 'pathname'

desc 'updates all submodules'
task :update do
  modules = collect_modules
  update_modules modules
  vendor_files modules
end

def collect_modules
  modules = []
  File.open('.gitmodules') do |f|
    contents = f.read
    contents.each_line do |line|
      modules << $1 if line =~ /\[submodule "(.*)"\]/
    end
  end
  modules
end

def main_files folders
  folders.map do |f|
    file_search = f.downcase
    file_search << '.js' unless file_search =~ /\.js$/

    path_order = ["./#{f}/pkg/#{file_search}", "./#{f}/#{file_search}", "./#{f}/lib/#{file_search}"]

    r = path_order.map do |p|
      p if File.exist? p
    end.flatten.compact.first
  end.flatten.compact
end

def vendor_files modules
  files = main_files modules
  puts "found #{files.length} of the #{modules.length} lib files" unless files.length == modules.length
  path = "./vendor/assets/javascripts/"
  Pathname.new(path).mkpath()
  FileUtils.cp files, path
end

def update_modules modules
  modules.each do |mod|
    `cd ./#{mod} && git pull`
    `cd ./#{mod} && ./build` if File.exist? "./#{mod}/build"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
konacha-chai-matchers-0.0.8 tasks/update.rb
konacha-chai-matchers-0.0.7 tasks/update.rb
konacha-chai-matchers-0.0.6 tasks/update.rb
konacha-chai-matchers-0.0.5 tasks/update.rb
konacha-chai-matchers-0.0.4 tasks/update.rb
konacha-chai-matchers-0.0.3 tasks/update.rb
konacha-chai-matchers-0.0.2 tasks/update.rb
konacha-chai-matchers-0.0.1 tasks/update.rb