Skip to content

Commit

Permalink
Fixed 'powder list' to display proxy ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
babysnakes committed Aug 28, 2012
1 parent a239515 commit 804b78b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bin/powder
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ require 'rubygems'
require 'thor'
require 'fileutils'
require 'net/https'
require 'powder'
require 'powder/version'

module Powder
class CLI < Thor
include Thor::Actions
include Powder
default_task :help

map '-r' => 'restart'
Expand Down Expand Up @@ -166,10 +168,10 @@ module Powder

desc "list", "List current pows"
def list
pows = Dir[POW_PATH + "/*"].map do |link|
realpath = File.readlink(link)
app_is_current = (realpath == Dir.pwd) ? '*' : ' '
[app_is_current, File.basename(link), realpath.gsub(ENV['HOME'], '~')]
pows = Dir[POW_PATH + "/*"].map do |link_or_port|
realpath_or_port = get_app_origin(link_or_port)
app_is_current = (realpath_or_port == Dir.pwd) ? '*' : ' '
[app_is_current, File.basename(link_or_port), realpath_or_port.gsub(ENV['HOME'], '~')]
end
print_table(pows)
end
Expand Down
10 changes: 10 additions & 0 deletions lib/powder.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
module Powder
# Get the origin of the application link, whether it's a link to a
# rack app or proxy to a port.
def get_app_origin(app_link)
if File.symlink? app_link
File.readlink(app_link)
else
port = File.readlines(app_link)[0]
"proxy port: #{port}"
end
end
end

0 comments on commit 804b78b

Please sign in to comment.