Class: Stencil::Cmd

Inherits:
Object
  • Object
show all
Defined in:
lib/stencil/cmd.rb

Class Method Summary collapse

Class Method Details

.run(path, cmd = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stencil/cmd.rb', line 5

def run(path, cmd=nil)
  if cmd.nil?
    cmd, path = path, cmd
  else
    path = "cd #{path} && "
  end
  
  output = `#{[ path, cmd ].compact.join} 2>&1`

  unless $?.success?
    Msg.error "#{cmd}\n\n#{output}"
  end

  output
end