Sha256: 0a1a77d83c99ebbe76b3d5d3ed23d22d340437a998f51661784fc609ca7c7b66

Contents?: true

Size: 1.34 KB

Versions: 51

Compression:

Stored size: 1.34 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}") 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

51 entries across 51 versions & 1 rubygems

Version Path
bastion-6.1.23 Rakefile
bastion-6.1.22 Rakefile
bastion-6.1.21 Rakefile
bastion-6.1.20 Rakefile
bastion-6.1.19 Rakefile
bastion-6.1.18 Rakefile
bastion-6.1.17 Rakefile
bastion-6.1.16 Rakefile
bastion-6.1.15 Rakefile
bastion-6.1.14 Rakefile
bastion-6.1.13 Rakefile
bastion-6.1.12 Rakefile
bastion-6.1.11 Rakefile
bastion-6.1.10 Rakefile
bastion-6.1.9 Rakefile
bastion-6.1.8 Rakefile
bastion-6.1.7 Rakefile
bastion-6.1.6 Rakefile
bastion-6.1.5 Rakefile
bastion-6.1.4 Rakefile