Sha256: ea212ebfc649e8ecff5736a30e063ac365a7fbd594a83149814fa3336474913a

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

require 'capistrano/i18n'
require 'dkdeploy/i18n'

include Capistrano::DSL

namespace :bower do
  desc 'Runs given Bower command in given path'
  task :run, :bower_command, :bower_path do |_, args|
    bower_command = ask_variable(args, :bower_command, 'questions.bower.command') { |question| question.default = 'help' }
    bower_path = ask_variable(args, :bower_path, 'questions.bower.path') { |question| question.default = 'htdocs' }

    run_locally do
      if test("[ -d #{bower_path} ]")
        bower_file_path = File.join(bower_path, 'bower.json')
        if test("[ -f #{bower_file_path} ]")
          within bower_path do
            execute :bower, bower_command
          end
        else
          warn I18n.t('tasks.bower.skipping_directory_with_missing_bower_file', bower_path: bower_path, scope: :dkdeploy)
          next
        end
      else
        warn I18n.t('tasks.bower.skipping_missing_directory', bower_path: bower_path, scope: :dkdeploy)
        next
      end
    end
  end

  task :run_all, :bower_command, :bower_paths do |_, args|
    bower_command = ask_variable(args, :bower_command, 'questions.bower.command') { |question| question.default = 'help' }
    bower_paths = ask_array_variable(args, :bower_paths, 'questions.bower.paths')

    run_locally do
      bower_paths.each do |bower_path|
        if test("[ -d #{bower_path} ]")
          current_bower_file_path = File.join(bower_path, 'bower.json')
          if test("[ -f #{current_bower_file_path} ]")
            within bower_path do
              execute :bower, bower_command
            end
          else
            warn I18n.t('tasks.bower.skipping_directory_with_missing_bower_file', bower_path: bower_path, scope: :dkdeploy)
            next
          end
        else
          warn I18n.t('tasks.bower.skipping_missing_directory', bower_path: bower_path, scope: :dkdeploy)
          next
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dkdeploy-core-9.1.1 lib/dkdeploy/tasks/bower.rake
dkdeploy-core-9.0.1 lib/dkdeploy/tasks/bower.rake
dkdeploy-core-9.1.0 lib/dkdeploy/tasks/bower.rake
dkdeploy-core-9.0.0 lib/dkdeploy/tasks/bower.rake