Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Add error handling to 'build' and 'update' #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/vulcan/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ def build
deps = options[:deps] || []
server = URI.parse(ENV["VULCAN_HOST"] || "http://#{app}.herokuapp.com")

source_is_url = URI.parse(source).scheme
begin
source_is_url = URI.parse(source).scheme
rescue URI::InvalidURIError
source_is_url = false
end

Dir.mktmpdir do |dir|
unless source_is_url
input_tgz = "#{dir}/input.tgz"
if File.directory?(source)
action "Packaging local directory" do
%x{ cd #{source} && tar czvf #{input_tgz} . 2>&1 }
output = %x{ cd #{source} && tar czvf #{input_tgz} . 2>&1 }
end
if not File.exists?(input_tgz)
error "Could not create package: '#{output}'"
end
else
input_tgz = source
Expand Down Expand Up @@ -148,12 +155,18 @@ def update
file.puts ".env"
end

system "git add . >/dev/null"
system "git commit -m commit >/dev/null"
devnull = '/dev/null'
if not File.exists?(devnull) and File.exists?('NUL')
devnull = 'NUL'
end

system "git add . >#{devnull}"
system "git commit -m commit >#{devnull}"
system "git push heroku -f master"

heroku "config:add SECRET=#{config[:secret]} SPAWN_ENV=heroku HEROKU_APP=#{config[:app]} HEROKU_API_KEY=#{api_key} NODE_PATH=lib NODE_ENV=production"
heroku "addons:add cloudant:oxygen"

end
end
end
Expand Down