def perform_command(remove_components = true, &block)
      # Load in bower json file
      txt  = File.read(File.join(root_path, "bower.json"))
      json = JSON.parse(txt)


      # Load and merge root .bowerrc
      dot_bowerrc = JSON.parse(File.read(File.join(root_path, '.bowerrc'))) rescue {}
      dot_bowerrc["directory"] = components_directory

      if json.reject{ |key| ['lib', 'vendor'].include? key }.empty?
        folders = json.keys
      else
        raise "Assuming a standard bower package but cannot find the required 'name' key" unless !!json['name']
        folders = ['vendor']
      end

      folders.each do |dir|
        data = json[dir]

        # Assume using standard bower.json if folder name is not found
        data = json if data.nil?

        # Check folder existence and create?
        dir = File.join(root_path, dir, "assets")
        FileUtils.mkdir_p dir unless File.directory? dir
        # Go in to dir to act
        Dir.chdir(dir) do

          # Remove old components
          FileUtils.rm_rf("#{components_directory}/*") if remove_components

          # Create bower.json
          File.open("bower.json", "w") do |f|
            f.write(data.to_json)
          end

          # Create .bowerrc
          File.open(".bowerrc", "w") do |f|
            f.write(JSON.pretty_generate(dot_bowerrc))
          end

          # Run command
          yield  if block_given?

          # Remove bower.json
          FileUtils.rm("bower.json")

          # Remove .bowerrc
          FileUtils.rm(".bowerrc")
        end if data && !data["dependencies"].empty?
      end
    end
def perform_command(remove_components = true, &block)
      # Load in bower json file
      txt  = File.read(File.join(root_path, "bower.json"))
      json = JSON.parse(txt)


      # Load and merge root .bowerrc
      dot_bowerrc = JSON.parse(File.read(File.join(root_path, '.bowerrc'))) rescue {}
      dot_bowerrc["directory"] = components_directory

      if json.reject{ |key| ['lib', 'vendor'].include? key }.empty?
        folders = json.keys
      else
        raise "Assuming a standard bower package but cannot find the required 'name' key" unless !!json['name']
        folders = ['vendor']
      end

      folders.each do |dir|
        data = json[dir]

        # Assume using standard bower.json if folder name is not found
        data = json if data.nil?

        # Check folder existence and create?
        dir = File.join(root_path, dir, "assets")
        FileUtils.mkdir_p dir unless File.directory? dir
        # Go in to dir to act
        Dir.chdir(dir) do

          # Remove old components
          FileUtils.rm_rf("#{components_directory}/*") if remove_components

          # Create bower.json
          File.open("bower.json", "w") do |f|
            f.write(data.to_json)
          end

          # Create .bowerrc
          File.open(".bowerrc", "w") do |f|
            f.write(JSON.pretty_generate(dot_bowerrc))
          end

          # Run command
          yield  if block_given?

          # Remove bower.json
          FileUtils.rm("bower.json")

          # Remove .bowerrc
          FileUtils.rm(".bowerrc")
        end if data && !data["dependencies"].empty?
      end
    end
run the passed bower block in appropriate folders