Sha256: fab70715943833ecee27c5d81c855f8dc228d5df938e6f17b45c0f3091918ab9

Contents?: true

Size: 1.54 KB

Versions: 9

Compression:

Stored size: 1.54 KB

Contents

# desc 'Explaining what the task does'
# task :avo do
#   # Task goes here
# end

desc "Installs Avo assets and bundles them for when you want to use the GitHub repo in your app"
task "avo:build-assets" do
  spec = get_gem_spec "avo"
  # Uncomment to enable only when the source is github.com
  # enabled = spec.source.to_s.include?('https://github.com/avo-hq/avo')
  enabled = true

  if enabled
    puts "Starting avo:build-assets"
    path = spec.full_gem_path

    Dir.chdir(path) do
      system "yarn"
      system "yarn prod:build"
    end

    puts "Done"
  else
    puts "Not starting avo:build-assets"
  end
end

# From
# https://stackoverflow.com/questions/9322078/programmatically-determine-gems-path-using-bundler
def get_gem_spec(name)
  spec = Bundler.load.specs.find { |s| s.name == name }
  raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
  if spec.name == "bundler"
    return File.expand_path("../../../", __FILE__)
  end

  spec
end

desc "Finds all Avo gems and outputs theyr paths"
task "avo:gem_paths" do
  config = YAML.load_file("../support/gems.yml")

  existing_gems = config["gems"].keys
    .map do |gem|
      path = `bundle show #{gem} 2> /dev/null`.chomp

      unless path.empty?
        "#{gem}:#{path}"
      end
    end
    .reject(&:nil?)
  result = existing_gems.join(",")

  # Outputs a CSV "hash-like" string in this format
  #
  # GEM_NAME:GEM_PATH,SECOND_GEM_NAME:SECOND_GEM_PATH
  # avo:/Users/adrian/work/avocado/avo-3,avo_filters:/Users/adrian/work/avocado/advanced/avo_filters
  puts result
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avo-3.0.0.pre8 lib/tasks/avo_tasks.rake
avo-3.0.0.pre9 lib/tasks/avo_tasks.rake
avo-3.0.0.pre7 lib/tasks/avo_tasks.rake
avo-3.0.0.pre5 lib/tasks/avo_tasks.rake
avo-3.0.0.pre6 lib/tasks/avo_tasks.rake
avo-3.0.0.pre4 lib/tasks/avo_tasks.rake
avo-3.0.0.pre3 lib/tasks/avo_tasks.rake
avo-3.0.0.pre2 lib/tasks/avo_tasks.rake
avo-3.0.0.pre1 lib/tasks/avo_tasks.rake