Sha256: 013f856b1dedae968711710a6cd1d67ff859f2825d6445754fdc22bac8b50b78

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Fanforce::CLI::Run
  require 'pty'

  def self.bundle_install(dir)
    Dir.chdir(dir) do
      command('gem install bundler') if Gem::Specification::find_all_by_name('bundler').empty?
      command('bundle install')
    end
  end

  def self.pow_create(app, root_domain)
    domain = "#{app._id}.#{root_domain}"

    symbolic_link = "#{ENV['HOME']}/.pow/#{domain.gsub('.gg','')}"
    File.delete(symbolic_link) if File.exists?(symbolic_link)
    `ln -s #{app.dir} #{symbolic_link}`
    puts "#{'Connected'.format(:bold,:green)} #{domain} to #{app.dir}/"
  end

  def self.pow_destroy(app, root_domain)
    domain = "#{app._id}.#{root_domain}"
    symbolic_link = "#{ENV['HOME']}/.pow/#{domain.gsub('.gg','')}"
    if File.exists?(symbolic_link)
      File.delete(symbolic_link)
      puts "#{'Removed'.format(:bold,:green)} #{domain}"
    else
      puts "#{'Already Removed'.format(:bold,:green)} #{domain} to #{app.dir}/"
    end
  end

  def self.git_init
    `git init`
  end

  def self.git_add
    `git add .`
  end

  def self.git_first_commit
    `git commit -m "initial fanforce commit"`
  end

  def self.command(command, print_now=true)
    output = []
    PTY.spawn(command) do |stdin, stdout, pid|
      stdin.each { |line| output << line; print line if print_now }
    end
    output.join("\n")
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fanforce-cli-1.2.0 lib/fanforce/cli/run.rb
fanforce-cli-1.1.0 lib/fanforce/cli/run.rb