lib/gitdocs/runner.rb in gitdocs-0.3.2 vs lib/gitdocs/runner.rb in gitdocs-0.3.3
- old
+ new
@@ -1,7 +1,9 @@
module Gitdocs
class Runner
+ include ShellTools
+
attr_reader :root, :listener
def initialize(share)
@share = share
@root = share.path
@@ -146,20 +148,12 @@
def sh_string(cmd, default=nil)
val = sh(cmd).strip rescue nil
(val.nil? || val.empty?) ? default : val
end
- def sh(cmd)
- out, code = sh_with_code(cmd)
- code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
- end
-
# Run in shell, return both status and output
# @see #sh
def sh_with_code(cmd)
- cmd << " 2>&1"
- outbuf = ''
- outbuf = `cd "#{@root}" && #{cmd}`
- [outbuf, $?]
+ ShellTools.sh_with_code(cmd, @root)
end
end
end