<commit_before>require 'json'
require 'pp'

namespace :bower do
  desc "Install components from bower"
  task :install do
    perform do
      sh 'bower install'
    end
  end

  namespace :install do
    desc "Install components with -F option"
    task :force do
      perform do
        sh 'bower install -F'
      end
    end
  end

  desc "Update bower components"
  task :update do
    perform do
      sh 'bower update'
    end
  end

  desc "List bower components"
  task :list do
    perform false do
      sh 'bower list'
    end
  end

  namespace :update do
    desc "Update existing components and uninstalls extraneous components"
    task :prune do
      perform do
        sh 'bower update && bower prune'
      end
    end
  end

  desc "Resolve assets paths in bower components"
  task :resolve do
    perform false do
      resolve_asset_paths
    end
  end
end

# Install bower assets before precompile
Rake::Task['assets:precompile'].enhance ['bower:install', 'bower:resolve']

def perform remove_components = true, &block
  entries = Dir.entries(get_bower_root_path)

  if entries.include?('Bowerfile')
    dsl_perform_command remove_components, &block
  elsif entries.include?('bower.json')
    perform_command remove_components, &block
  else<commit_msg>temporary remove running bower tasks before assets precompilation<commit_after>require 'json'
require 'pp'

namespace :bower do
  desc "Install components from bower"
  task :install do
    perform do
      sh 'bower install'
    end
  end

  namespace :install do
    desc "Install components with -F option"
    task :force do
      perform do
        sh 'bower install -F'
      end
    end
  end

  desc "Update bower components"
  task :update do
    perform do
      sh 'bower update'
    end
  end

  desc "List bower components"
  task :list do
    perform false do
      sh 'bower list'
    end
  end

  namespace :update do
    desc "Update existing components and uninstalls extraneous components"
    task :prune do
      perform do
        sh 'bower update && bower prune'
      end
    end
  end

  desc "Resolve assets paths in bower components"
  task :resolve do
    perform false do
      resolve_asset_paths
    end
  end
end

# Install bower assets before precompile
# Rake::Task['assets:precompile'].enhance ['bower:install', 'bower:resolve']

def perform remove_components = true, &block
  entries = Dir.entries(get_bower_root_path)

  if entries.include?('Bowerfile')
    dsl_perform_command remove_components, &block
  elsif entries.include?('bower.json')
    perform_command remove_components, &block
  else
{'fraction_non_alphanumeric': 0.06475095785440613, 'fraction_numerical': 0.0, 'mean_word_length': 2.950075642965204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4698540', 'n_tokens_mistral': 787, 'n_tokens_neox': 776, 'n_words': 284}