rerun 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1489afa035f2da5780ee35de95b95bd272c5440
4
- data.tar.gz: 2610078f1caaf80bb29540fd398149b539b88b12
3
+ metadata.gz: 9e76ba084873582659cd7594bc0dd2bb16f59848
4
+ data.tar.gz: 8c19a2d63d189d9876ba85f6b344539b8cbb3c2f
5
5
  SHA512:
6
- metadata.gz: ff6bf2054ab858b4a9bfde9600ffb5966be77c63584e1049bf2f4299b01b437fe5fdf83b7e890b55d2ab249243d02cd60ad035ce2ad1145d83f904f9a53b272e
7
- data.tar.gz: 88f0dd6fd81c98ab774a4ab2f5a7f545b827f3295d19a4613a0504b42e6de0dd4a13a5d6381e59a43f0f067aca3100ff4d2b177bb3a46f723100c85d369c7764
6
+ metadata.gz: 966e3c6d41605dfce0df54232dfeba72dcd805ad30c62a544bc487a9b93af7f8ea2f926efe203519c3201aaab596581ecab165fc17b3817ca0695f319220fdfa
7
+ data.tar.gz: f2276408f9d310cfff3fa637edf29d5e636206ebbacdecfbd75c42244e5431f8eb5e2b5df0d4303e6792f2f5fdc845c499f2806725db8eef36a5e10581d89ede
data/README.md CHANGED
@@ -126,6 +126,8 @@ Procfile processes locally and restart them all when necessary.
126
126
 
127
127
  # Options:
128
128
 
129
+ These options can be specified on the command line and/or inside a `.rerun` config file (see below).
130
+
129
131
  `--dir` directory (or directories) to watch (default = "."). Separate multiple paths with ',' and/or use multiple `-d` options.
130
132
 
131
133
  `--pattern` glob to match inside directory. This uses the Ruby Dir glob style -- see <http://www.ruby-doc.org/core/classes/Dir.html#M002322> for details.
@@ -167,6 +169,23 @@ This may be useful for forcing the respective process to terminate as quickly as
167
169
 
168
170
  Also `--version` and `--help`, naturally.
169
171
 
172
+ ## Config file
173
+
174
+ If the current directory contains a file named `.rerun`, it will be parsed with the same rules as command-line arguments. Newlines are the same as any other whitespace, so you can stack options vertically, like this:
175
+
176
+ ```
177
+ --quiet
178
+ --pattern **/*.{rb,js,scss,sass,html,md}
179
+ ```
180
+
181
+ Options specified on the command line will override those in the config file. You can negate boolean options with `--no-`, so for example, with the above config file, to re-enable logging, you could say:
182
+
183
+ ```sh
184
+ rerun --no-quiet rackup
185
+ ```
186
+
187
+ If you're not sure what options are being overwritten, use `--verbose` and rerun will show you the final result of the parsing.
188
+
170
189
  # Notifications
171
190
 
172
191
  If you have `growlnotify` available on the `PATH`, it sends notifications to
@@ -250,11 +269,11 @@ rerun -p "**/*.rb" rake test
250
269
  # To Do:
251
270
 
252
271
  ## Must have for v1.0
253
- * ".rerun" file to specify options per project or in $HOME.
254
272
  * Make sure to pass through quoted options correctly to target process [bug]
255
273
  * Optionally do "bundle install" before and "bundle exec" during launch
256
274
 
257
275
  ## Nice to have
276
+ * ".rerun" file in $HOME
258
277
  * If the last element of the command is a `.ru` file and there's no other command then use `rackup`
259
278
  * Figure out an algorithm so "-x" is not needed (if possible) -- maybe by accepting a "--port" option or reading `config.ru`
260
279
  * Specify (or deduce) port to listen for to determine success of a web server launch
@@ -368,6 +387,10 @@ Based upon and/or inspired by:
368
387
 
369
388
  # Version History
370
389
 
390
+ * v0.13.0 26 January 2018
391
+ * bugfix: pause/unpause works again (thanks Barry!)
392
+ * `.rerun` config file
393
+
371
394
  * v0.12.0 23 January 2018
372
395
  * smarter `--signal` option, allowing you to specify a series of signals to try in order; also `--wait` to change how long between tries
373
396
  * `--force-polling` option (thanks ajduncan)
data/Rakefile CHANGED
@@ -31,12 +31,13 @@ end
31
31
 
32
32
  desc 'Exit if git is dirty'
33
33
  task :check_git do
34
- # state = `git status 2> /dev/null | tail -n1`
35
- # clean = (state =~ /working (directory|tree) clean/)
36
- # unless clean
37
- # warn "can't do that on an unclean git dir"
38
- # exit 1
39
- # end
34
+ state = `git status 2> /dev/null | tail -n1`
35
+ clean = (state =~ /working (directory|tree) clean/)
36
+ unless clean
37
+ puts state
38
+ warn "can't do that on an unclean git dir"
39
+ # exit 1
40
+ end
40
41
  end
41
42
 
42
43
  desc 'Build packages'
data/bin/rerun CHANGED
@@ -7,6 +7,12 @@ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
7
7
  require 'rerun'
8
8
  require 'optparse'
9
9
 
10
- options = Rerun::Options.parse
11
- exit if options.nil?
12
- runner = Rerun::Runner.keep_running(options[:cmd], options)
10
+ options = Rerun::Options.parse config_file: ".rerun"
11
+
12
+ if options and options[:verbose]
13
+ puts "\nrerun options:\n\t#{options}"
14
+ end
15
+
16
+ exit if options.nil? or options[:cmd].nil? or options[:cmd].empty?
17
+
18
+ Rerun::Runner.keep_running(options[:cmd], options)
@@ -17,126 +17,129 @@ module Rerun
17
17
  DEFAULT_DIRS = ["."]
18
18
 
19
19
  DEFAULTS = {
20
- :pattern => DEFAULT_PATTERN,
21
- :signal => (windows? ? "TERM,KILL" : "TERM,INT,KILL"),
22
- :wait => 2,
23
- :notify => true,
24
- :quiet => false,
25
- :verbose => false,
26
- :name => Pathname.getwd.basename.to_s.capitalize,
27
- :ignore => [],
28
- :dir => DEFAULT_DIRS,
29
- :force_polling => false,
20
+ :pattern => DEFAULT_PATTERN,
21
+ :signal => (windows? ? "TERM,KILL" : "TERM,INT,KILL"),
22
+ :wait => 2,
23
+ :notify => true,
24
+ :quiet => false,
25
+ :verbose => false,
26
+ :background => false,
27
+ :name => Pathname.getwd.basename.to_s.capitalize,
28
+ :ignore => [],
29
+ :dir => DEFAULT_DIRS,
30
+ :force_polling => false,
30
31
  }
31
32
 
32
- def self.parse args = ARGV
33
+ def self.parse args: ARGV, config_file: nil
33
34
 
34
35
  default_options = DEFAULTS.dup
35
36
  options = {
36
- ignore: []
37
+ ignore: []
37
38
  }
38
39
 
39
- opts = OptionParser.new("", 24, ' ') do |opts|
40
- opts.banner = "Usage: rerun [options] [--] cmd"
40
+ if config_file && File.exist?(config_file)
41
+ require 'shellwords'
42
+ config_args = File.read(config_file).shellsplit
43
+ args = config_args + args
44
+ end
45
+
46
+ option_parser = OptionParser.new("", 24, ' ') do |o|
47
+ o.banner = "Usage: rerun [options] [--] cmd"
41
48
 
42
- opts.separator ""
43
- opts.separator "Launches an app, and restarts it when the filesystem changes."
44
- opts.separator "See http://github.com/alexch/rerun for more info."
45
- opts.separator "Version: #{$spec.version}"
46
- opts.separator ""
47
- opts.separator "Options:"
49
+ o.separator ""
50
+ o.separator "Launches an app, and restarts it when the filesystem changes."
51
+ o.separator "See http://github.com/alexch/rerun for more info."
52
+ o.separator "Version: #{$spec.version}"
53
+ o.separator ""
54
+ o.separator "Options:"
48
55
 
49
- opts.on("-d dir", "--dir dir", "directory to watch, default = \"#{DEFAULT_DIRS}\". Specify multiple paths with ',' or separate '-d dir' option pairs.") do |dir|
56
+ o.on("-d dir", "--dir dir", "directory to watch, default = \"#{DEFAULT_DIRS}\". Specify multiple paths with ',' or separate '-d dir' option pairs.") do |dir|
50
57
  elements = dir.split(",")
51
58
  options[:dir] = (options[:dir] || []) + elements
52
59
  end
53
60
 
54
61
  # todo: rename to "--watch"
55
- opts.on("-p pattern", "--pattern pattern", "file glob to watch, default = \"#{DEFAULTS[:pattern]}\"") do |pattern|
62
+ o.on("-p pattern", "--pattern pattern", "file glob to watch, default = \"#{DEFAULTS[:pattern]}\"") do |pattern|
56
63
  options[:pattern] = pattern
57
64
  end
58
65
 
59
- opts.on("-i pattern", "--ignore pattern", "file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g. --ignore 'coverage/*'") do |pattern|
66
+ o.on("-i pattern", "--ignore pattern", "file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g. --ignore 'coverage/*'") do |pattern|
60
67
  options[:ignore] += [pattern]
61
68
  end
62
69
 
63
- opts.on("-s signal", "--signal signal", "terminate process using this signal. To try several signals in series, use a comma-delimited list. Default: \"#{DEFAULTS[:signal]}\"") do |signal|
70
+ o.on("-s signal", "--signal signal", "terminate process using this signal. To try several signals in series, use a comma-delimited list. Default: \"#{DEFAULTS[:signal]}\"") do |signal|
64
71
  options[:signal] = signal
65
72
  end
66
73
 
67
- opts.on("-w sec", "--wait sec", "after asking the process to terminate, wait this long (in seconds) before either aborting, or trying the next signal in series. Default: #{DEFAULTS[:wait]} sec")
74
+ o.on("-w sec", "--wait sec", "after asking the process to terminate, wait this long (in seconds) before either aborting, or trying the next signal in series. Default: #{DEFAULTS[:wait]} sec")
68
75
 
69
- opts.on("-r", "--restart", "expect process to restart itself, so just send a signal and continue watching. Uses the HUP signal unless overridden using --signal") do |signal|
76
+ o.on("-r", "--restart", "expect process to restart itself, so just send a signal and continue watching. Uses the HUP signal unless overridden using --signal") do |signal|
70
77
  options[:restart] = true
71
78
  default_options[:signal] = "HUP"
72
79
  end
73
80
 
74
- opts.on("-x", "--exit", "expect the program to exit. With this option, rerun checks the return value; without it, rerun checks that the process is running.") do |dir|
75
- options[:exit] = true
81
+ o.on("-x", "--exit", "expect the program to exit. With this option, rerun checks the return value; without it, rerun checks that the process is running.") do |value|
82
+ options[:exit] = value
76
83
  end
77
84
 
78
- opts.on("-c", "--clear", "clear screen before each run") do
79
- options[:clear] = true
85
+ o.on("-c", "--clear", "clear screen before each run") do |value|
86
+ options[:clear] = value
80
87
  end
81
88
 
82
- opts.on("-b", "--background", "disable on-the-fly commands, allowing the process to be backgrounded") do
83
- options[:background] = true
89
+ o.on("-b", "--background", "disable on-the-fly commands, allowing the process to be backgrounded") do |value|
90
+ options[:background] = value
84
91
  end
85
92
 
86
- opts.on("-n name", "--name name", "name of app used in logs and notifications, default = \"#{DEFAULTS[:name]}\"") do |name|
93
+ o.on("-n name", "--name name", "name of app used in logs and notifications, default = \"#{DEFAULTS[:name]}\"") do |name|
87
94
  options[:name] = name
88
95
  end
89
96
 
90
- opts.on("--force-polling", "use polling instead of a native filesystem scan (useful for Vagrant)") do
91
- options[:force_polling] = true
97
+ o.on("--[no-]force-polling", "use polling instead of a native filesystem scan (useful for Vagrant)") do |value|
98
+ options[:force_polling] = value
92
99
  end
93
100
 
94
- opts.on("--no-growl", "don't use growl [OBSOLETE]") do
101
+ o.on("--no-growl", "don't use growl [OBSOLETE]") do
95
102
  options[:growl] = false
96
103
  $stderr.puts "--no-growl is obsolete; use --no-notify instead"
97
104
  return
98
105
  end
99
106
 
100
- opts.on("--[no-]notify [notifier]", "send messages through a desktop notification application. Supports growl (requires growlnotify), osx (requires terminal-notifier gem), and notify-send on GNU/Linux (notify-send must be installed)") do |notifier|
107
+ o.on("--[no-]notify [notifier]", "send messages through a desktop notification application. Supports growl (requires growlnotify), osx (requires terminal-notifier gem), and notify-send on GNU/Linux (notify-send must be installed)") do |notifier|
101
108
  notifier = true if notifier.nil?
102
109
  options[:notify] = notifier
103
110
  end
104
111
 
105
- opts.on("-q", "--quiet", "don't output any logs") do
106
- options[:quiet] = true
112
+ o.on("-q", "--[no-]quiet", "don't output any logs") do |value|
113
+ options[:quiet] = value
107
114
  end
108
115
 
109
- opts.on("--verbose", "log extra stuff like PIDs (unless you also specified `--quiet`") do
110
- options[:verbose] = true
116
+ o.on("--[no-]verbose", "log extra stuff like PIDs (unless you also specified `--quiet`") do |value|
117
+ options[:verbose] = value
111
118
  end
112
119
 
113
- opts.on_tail("-h", "--help", "--usage", "show this message") do
114
- puts opts
120
+ o.on_tail("-h", "--help", "--usage", "show this message and immediately exit") do
121
+ puts o
115
122
  return
116
123
  end
117
124
 
118
- opts.on_tail("--version", "show version") do
125
+ o.on_tail("--version", "show version and immediately exit") do
119
126
  puts $spec.version
120
127
  return
121
128
  end
122
129
 
123
- opts.on_tail ""
124
- opts.on_tail "On top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot."
130
+ o.on_tail ""
131
+ o.on_tail "On top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot."
125
132
 
126
133
  end
127
134
 
128
- if args.empty?
129
- puts opts
130
- nil
131
- else
132
- opts.parse! args
133
- default_options[:cmd] = args.join(" ")
135
+ option_parser.parse! args
136
+ options = default_options.merge(options)
137
+ options[:cmd] = args.join(" ").strip # todo: better arg word handling
134
138
 
135
- options = default_options.merge(options)
139
+ puts option_parser if args.empty?
136
140
 
137
- options
138
- end
141
+ options
139
142
  end
140
-
141
143
  end
144
+
142
145
  end
@@ -37,7 +37,7 @@ module Rerun
37
37
  say "Stopping and starting"
38
38
  restart(false)
39
39
  when 'p'
40
- toggle_pause if watcher_running?
40
+ toggle_pause
41
41
  when 'x', 'q'
42
42
  die
43
43
  break # the break will stop this thread, in case the 'die' doesn't
@@ -74,10 +74,6 @@ module Rerun
74
74
  @restarting = false
75
75
  end
76
76
 
77
- def watcher_running?
78
- @watcher && @watcher.running?
79
- end
80
-
81
77
  def toggle_pause
82
78
  unless @pausing
83
79
  say "Pausing. Press 'p' again to resume."
@@ -333,6 +329,10 @@ module Rerun
333
329
  puts "#{Time.now.strftime("%T")} [rerun] #{msg}" unless quiet?
334
330
  end
335
331
 
332
+ def stty(args)
333
+ system "stty #{args}"
334
+ end
335
+
336
336
  # non-blocking stdin reader.
337
337
  # returns a 1-char string if a key was pressed; otherwise nil
338
338
  #
@@ -346,7 +346,7 @@ module Rerun
346
346
  # looks like "raw" flips off the OPOST bit 0x00000001 /* enable following output processing */
347
347
  # which disables #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
348
348
  # so this sets it back on again since all we care about is raw input, not raw output
349
- system("stty raw opost")
349
+ stty "raw opost"
350
350
 
351
351
  c = nil
352
352
  if $stdin.ready?
@@ -354,9 +354,10 @@ module Rerun
354
354
  end
355
355
  c.chr if c
356
356
  ensure
357
- system "stty -raw" # turn raw input off
357
+ stty "-raw" # turn raw input off
358
358
  end
359
359
 
360
+
360
361
  # note: according to 'man tty' the proper way restore the settings is
361
362
  # tty_state=`stty -g`
362
363
  # ensure
@@ -62,7 +62,8 @@ module Rerun
62
62
 
63
63
  @thread = Thread.new do
64
64
  @listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1, force_polling: @force_polling) do |modified, added, removed|
65
- if((modified.size + added.size + removed.size) > 0)
65
+ count = modified.size + added.size + removed.size
66
+ if count > 0
66
67
  @client_callback.call(:modified => modified, :added => added, :removed => removed)
67
68
  end
68
69
  end
@@ -3,7 +3,7 @@ $spec = Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'rerun'
6
- s.version = '0.12.0'
6
+ s.version = '0.13.0'
7
7
 
8
8
  s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
9
9
  s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen