Sha256: f1e325908be82839542b24eb85e9bf24600bd2ed2328f73dc0f9c7732a9d8dab
Contents?: true
Size: 1.3 KB
Versions: 17
Compression:
Stored size: 1.3 KB
Contents
module DevboxLauncher class Watchman attr_reader :dir def initialize(dir:) @dir = dir end def trigger(command) UNIXSocket.open(sockname) do |socket| root = Pathname.new(dir).expand_path.to_s result = RubyWatchman.query(['watch-list'], socket) roots = result['roots'] if !roots.include?(root) # this path isn't being watched yet; try to set up watch result = RubyWatchman.query(['watch-project', root], socket) # root_restrict_files setting may prevent Watchman from working raise "Unable to watch #{dir}" if result.has_key?('error') end query = ['trigger', root, { 'name' => 'mutagen-sync', 'expression' => ['match', '**/*', 'wholename'], 'command' => command.split(" "), }] paths = RubyWatchman.query(query, socket) # could return error if watch is removed if paths.has_key?('error') raise "Unable to set trigger. Error: #{paths['error']}" end end end def sockname sockname = RubyWatchman.load( %x{watchman --output-encoding=bser get-sockname} )['sockname'] if !$?.exitstatus.zero? raise "Failed to connect to watchman. Is it running?" end sockname end end end
Version data entries
17 entries across 17 versions & 1 rubygems