Sfoglia il codice sorgente

Rescuing errors of rake docker task

Alax Alves 6 anni fa
parent
commit
ae2f8802ae
2 ha cambiato i file con 15 aggiunte e 3 eliminazioni
  1. 1 1
      README.md
  2. 14 2
      Rakefile

+ 1 - 1
README.md

@@ -376,7 +376,7 @@ bundle exec rake test
 
 or if you'd rather use docker just run:
 ```bash
-docker run -it --name shopify_api -v $PWD:/shopify_api -w="/shopify_api" ruby:2.4.6 bundle install
+docker run -it --name shopify_api -v "$PWD:/shopify_api" -w="/shopify_api" ruby:2.4.6 bundle install
 docker exec -it shopify_api bash
 ```
 

+ 14 - 2
Rakefile

@@ -38,9 +38,21 @@ Rake::RDocTask.new do |rdoc|
   rdoc.rdoc_files.include('lib/**/*.rb')
 end
 
+require 'open-uri'
+def internet_connection?
+  begin
+    true if open("8.8.8.8")
+  rescue
+    false
+  end
+end
+
 task :docker do
   cmd = "docker-compose up -d && docker exec -i -t shopify_api bash"
-  unless system(cmd, err: File::NULL)
-    abort("Something went wrong, do you have Docker and Docker-Compose installed?")
+  begin
+    system(cmd, err: File::NULL)
+    raise RuntimeError.new("There is no internet connection") unless internet_connection?
+  rescue => e
+    puts e.inspect
   end
 end