watch_and_do 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/watch_and_do +13 -4
  2. metadata +1 -1
@@ -9,6 +9,11 @@ Example: watch_and_do /tmp/ss js,coffee,rb /tmp/do.rb
9
9
  Example: watch_and_do . coffee ./rebuild.sh
10
10
  "
11
11
 
12
+ opts.on( '-v', '--version', 'Displays this screen' ) do
13
+ puts eval(File.new("./../watch_and_do.gemspec", "r").read).version
14
+ exit
15
+ end
16
+
12
17
  opts.on( '-h', '--help', 'Displays this screen' ) do
13
18
  puts opts
14
19
  exit
@@ -33,8 +38,7 @@ if ARGV.size == 3
33
38
 
34
39
  dir = File.new get_full_path(ARGV[0])
35
40
  extensions = ARGV[1].split(',')
36
- script = ARGV[2]
37
-
41
+ script = File.new get_full_path(ARGV[2])
38
42
 
39
43
  # validation (path + script exist)
40
44
  if !File::exists? dir
@@ -42,10 +46,14 @@ if ARGV.size == 3
42
46
  puts "invalid directory name"
43
47
  end
44
48
 
49
+ script_path = File.expand_path script
50
+ dir_path = File.expand_path dir
51
+
45
52
  if valid
53
+ puts "\nNow watching #{dir_path} and executing #{script_path}"
46
54
  # start watch + call script on modified file
47
55
  while true do
48
- line = %x[inotifywait -e modify -q -r #{dir.path}]
56
+ line = %x[inotifywait -e modify -q -r #{dir_path}]
49
57
 
50
58
  words = line.split(' MODIFY ')
51
59
 
@@ -54,7 +62,8 @@ if ARGV.size == 3
54
62
 
55
63
  extensions.each do |ext|
56
64
  if filename.end_with? ext
57
- puts %x[#{script} #{filename}]
65
+ puts "#{script_path} #{filename}"
66
+ puts %x[#{script_path} #{filename} &]
58
67
  break
59
68
  end
60
69
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: watch_and_do
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - hbt