Sha256: 0bfa15758926efe2b0b1e25cc67f63c0e4b8270a6a53e1e4612b26d12806cb27

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 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
    response = `git init`
    `git config core.fileMode false`
    return response
  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

5 entries across 5 versions & 1 rubygems

Version Path
fanforce-cli-1.7.1 lib/fanforce/cli/run.rb
fanforce-cli-1.7.0 lib/fanforce/cli/run.rb
fanforce-cli-1.6.0 lib/fanforce/cli/run.rb
fanforce-cli-1.5.0 lib/fanforce/cli/run.rb
fanforce-cli-1.4.0 lib/fanforce/cli/run.rb