Sha256: f20633828057fcb818264e94a2df4e00832c51a5e920b92fd8254aa750559077

Contents?: true

Size: 1.35 KB

Versions: 12

Compression:

Stored size: 1.35 KB

Contents

require 'open3'
require 'bastion/engine'

namespace :bastion do

  desc 'Run linting and tests for the plugin'
  task 'ci' do
    success = grunt('ci')
    exit!(1) if !success
  end

  desc 'Run any grunt task by specifying the argument'
  task 'grunt', [:task] do |task, args|
    success = grunt(args[:task])
    exit!(1) if !success
  end

  desc 'Setup development environment'
  task 'setup' do
    puts "Setting up development environment"

    setup_npm
  end

end

def grunt(command)
  syscall("grunt #{command}")
end

def bastion_core?
  Dir.pwd.split('/').last == 'bastion'
end

def setup_npm
  syscall('sudo yum install -y nodejs npm') if !system('rpm -q nodejs') || !system('rpm -q npm')
  syscall('sudo npm -g install grunt-cli bower yo phantomjs')

  puts "Installing NPM dependencies"
  syscall("npm install #{Bastion::Engine.root} grunt") if !bastion_core?
  syscall("npm install") if File.exist?('package.json')
  syscall("bower install") if bastion_core?
end

def syscall(*cmd)
  Open3.popen3(*cmd) do |stdin, stdout, stderr, thread|

    # read each stream from a new thread
    { :out => stdout, :err => stderr }.each do |key, stream|
      Thread.new do
        until (raw_line = stream.gets).nil? do
          puts raw_line
        end
      end
    end

    thread.join # don't exit until the external process is done
    thread.value.success?
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bastion-3.3.5 Rakefile
bastion-3.3.4 Rakefile
bastion-3.3.3 Rakefile
bastion-3.3.2 Rakefile
bastion-3.3.1 Rakefile
bastion-3.3.0 Rakefile
bastion-3.2.2 Rakefile
bastion-3.2.1 Rakefile
bastion-3.2.0 Rakefile
bastion-3.1.0 Rakefile
bastion-3.0.1 Rakefile
bastion-3.0.0 Rakefile