Module: FSWatch

Defined in:
lib/fswatch.rb

Class Method Summary collapse

Class Method Details

.run_command(directories) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fswatch.rb', line 12

def FSWatch.run_command(directories)
  print red, "\n\n--- Changed: ", bold, blue, directories.inspect, reset, "\n"
  if @processPid 
    status = Process.wait(@processPid, Process::WNOHANG)
    if @opts[:kill] && status == nil
      print red, "!!! Killing #{@processPid}", reset, "\n"
      Process.kill("KILL", @processPid)
    end
  end

  command = ARGV.join(' ')
  command.sub!("@fspathscolon", directories.join(':'))
  command.sub!("@fspathscomma", directories.join(','))
  command.sub!("@fspaths", directories.join(' '))

  if @opts[:paths]
    command << ' ' << directories.join(' ')
  end
   
  @processPid = fork {
    system(command)
  }
end