io-watch 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acb60fab33220f774934fac55057df2ecbcdb5227b9014313d9c541d23642cdd
4
- data.tar.gz: ac530c9cd6e504669a07f96e21515ad968504fa89783e19d49bc250774db30c8
3
+ metadata.gz: 197b7721bf73d747ba737369fc907fb390c9d1b76fcf673918476fb25ff31fd5
4
+ data.tar.gz: 7eb67828008e3680fcc86512b624630b2f3bf26731c1b7e14373ab5719e33609
5
5
  SHA512:
6
- metadata.gz: 256a699bc203c6e0036a54c15ec914f4b197016d0ee35b31cdc160ddecc2ef334e176fefdf4cd4402f817c42994342b66f0e127da19aa0436285b4628c3bce36
7
- data.tar.gz: 159434b858a76c0825207d438a408d45a5013733a83283213a97721769582407c18fd81482f7efca1fe5492d6ae11cf377355c4f4ea20c93ddf8501d55df291b
6
+ metadata.gz: 1100eb530ebc9684d833394c0eda71383a7248959b4b7757ec1587e50a1db0691abe8afcdf2322b4718f95536ab796f59a3ed235d7d4f58ac6120aef68bf4f78
7
+ data.tar.gz: 3aeb06da9803b9242be48fe66a423578011614423732c5a6f7a90772a19fade4eb471b1efb631043b06f83b70ecc9f1554e47b671d55c0b468a61c3cd8ad1c3c
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/io-watch CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'console'
4
4
  require 'io/watch'
5
5
 
6
- root = Dir.pwd
7
6
  command = ARGV
8
7
  pid = nil
9
8
  signal = :INT
@@ -12,16 +11,42 @@ if command.first =~ /TERM|INT|KILL|QUIT|HUP/
12
11
  signal = command.shift
13
12
  end
14
13
 
15
- monitor = IO::Watch::Monitor.new([root])
14
+ if split = command.index('--')
15
+ roots = command.shift(split)
16
+ command.shift
17
+ else
18
+ roots = [Dir.pwd]
19
+ end
20
+
21
+ Console.debug(self, "Watching", roots: roots, command: command, signal: signal)
22
+
23
+ if command.empty?
24
+ Console.error(self, "No command given")
25
+ exit 1
26
+ end
27
+
28
+ if roots.empty?
29
+ Console.error(self, "No roots given")
30
+ exit 1
31
+ end
32
+
33
+ monitor = IO::Watch::Monitor.new(roots)
16
34
 
17
- monitor.run do
18
- if pid
19
- Console.info(self, "Killing command...", pid: pid)
20
- Process.kill(signal, pid)
21
- Process.wait(pid)
35
+ begin
36
+ monitor.run do
37
+ if pid
38
+ Console.debug(self, "Killing command...", pid: pid)
39
+ Process.kill(signal, pid)
40
+ Process.wait(pid)
41
+ end
42
+
43
+ Console.debug(self, "Starting command...")
44
+ pid = Process.spawn(*command)
45
+ Console.debug(self, "Started command", pid: pid)
22
46
  end
23
-
24
- Console.info(self, "Starting command...")
25
- pid = Process.spawn(*command)
26
- Console.info(self, "Started command", pid: pid)
47
+ rescue Interrupt
48
+ # Ignore.
49
+ ensure
50
+ Process.kill('TERM', pid)
51
+ Process.wait(pid)
27
52
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  class IO
7
7
  module Watch
8
- VERSION = '0.3.0'
8
+ VERSION = '0.4.1'
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file