From 6e6de72a34677c9dd631f736b8368de526040580 Mon Sep 17 00:00:00 2001 From: Brandt Lareau Date: Tue, 25 Sep 2018 14:11:33 -0700 Subject: [PATCH] Made the installer not print the install process --- gem_installer.rb | 34 ++++++++++++++++++++++++---------- info.plist | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gem_installer.rb b/gem_installer.rb index 49f4017..21ed535 100644 --- a/gem_installer.rb +++ b/gem_installer.rb @@ -11,23 +11,37 @@ module GemInstaller def install(lib) - return false if `gem list #{lib}`.include?(lib) - Logger.info("running 'install #{lib} --no-ri --no-rdoc'") - Gem::GemRunner.new.run(['install', lib, '--no-ri', '--no-rdoc']) - Logger.info("failed to 'install #{lib} --no-ri --no-rdoc'") - false + suppress_output do + return false if `gem list #{lib}`.include?(lib) + Logger.info("running 'install #{lib} --no-ri --no-rdoc'") + Gem::GemRunner.new.run(['install', lib, '--no-ri', '--no-rdoc']) + Logger.info("failed to 'install #{lib} --no-ri --no-rdoc'") + false + end rescue Gem::SystemExitException Logger.info("Successfully Installed #{lib}") true end def reinstall(lib) - return install(lib) unless `gem list #{lib}`.include?(lib) - Logger.info("Uninstalling #{lib}") - Gem::GemRunner.new.run(['uninstall', lib, '-a']) - Logger.info("Failed to uninstall #{lib}") - install(lib) + suppress_output do + return install(lib) unless `gem list #{lib}`.include?(lib) + Logger.info("Uninstalling #{lib}") + Gem::GemRunner.new.run(['uninstall', lib, '-a']) + Logger.info("Failed to uninstall #{lib}") + install(lib) + end rescue StandardError => exception Logger.error("Failure #{exception.message}") end + + def suppress_output + original_stdout, original_stderr = $stdout.clone, $stderr.clone + $stderr.reopen File.new('/dev/null', 'w') + $stdout.reopen File.new('/dev/null', 'w') + yield + ensure + $stdout.reopen original_stdout + $stderr.reopen original_stderr + end end diff --git a/info.plist b/info.plist index 673c4be..3c89c35 100644 --- a/info.plist +++ b/info.plist @@ -195,7 +195,7 @@ end queuemode 1 runningsubtext - Loading Classes... + Downloading Faker Gem.... script query = ARGV[0].to_s.downcase require 'json'