demotape 0.0.8 → 0.0.9

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.
@@ -35,7 +35,11 @@ module DemoTape
35
35
  error_message = error.message if error.respond_to?(:message)
36
36
 
37
37
  thor.say_error "\nERROR: #{error_message}", :red
38
- puts error.backtrace if error.respond_to?(:backtrace)
38
+
39
+ if !error.is_a?(TimeoutError) && error.respond_to?(:backtrace)
40
+ puts error.backtrace
41
+ end
42
+
39
43
  exit 1
40
44
  end
41
45
 
@@ -166,6 +170,7 @@ module DemoTape
166
170
  end
167
171
 
168
172
  def run
173
+ Thread.report_on_exception = false
169
174
  Thread.abort_on_exception = true
170
175
  Capybara.default_driver = :selenium_chrome_headless
171
176
 
@@ -175,8 +180,8 @@ module DemoTape
175
180
  thor.say_status :info, "Using #{thor.set_color(options.shell, :blue)}"
176
181
  debug "Running preflight checks"
177
182
  preflight_checks
178
-
179
183
  resolve_includes
184
+
180
185
  if options.screenshot
181
186
  commands << Command.new("Screenshot", "",
182
187
  tokens: [Token::Identifier.new("Screenshot")])
@@ -187,10 +192,25 @@ module DemoTape
187
192
  run_meta_commands
188
193
  resolve_output_paths
189
194
  setup_tmp_dir
190
- start_ttyd
191
- resize_browser_window
192
- send_ttyd_options
195
+ exited = false
193
196
 
197
+ handler = proc do
198
+ exited = true
199
+ exit 1
200
+ end
201
+
202
+ Signal.trap("SIGINT", &handler)
203
+ Signal.trap("SIGQUIT", &handler)
204
+
205
+ Thread.new do
206
+ start_ttyd
207
+ resize_browser_window
208
+ send_ttyd_options
209
+ rescue StandardError
210
+ raise unless exited
211
+ end.join
212
+
213
+ threads << timeout
194
214
  threads << recorder
195
215
  threads << executor(commands)
196
216
  threads.each(&:join)
@@ -208,6 +228,25 @@ module DemoTape
208
228
  ttyd.stop
209
229
  end
210
230
 
231
+ def timeout
232
+ Thread.new do
233
+ tick = 0.01
234
+ timeout = Duration.parse(options.timeout).to_i
235
+ next unless timeout.positive?
236
+
237
+ while timeout.positive?
238
+ break unless read_state(:keep_recording)
239
+
240
+ sleep tick
241
+ timeout -= tick
242
+ end
243
+
244
+ unless timeout.positive?
245
+ raise TimeoutError, "Demo tape execution timed out"
246
+ end
247
+ end
248
+ end
249
+
211
250
  def ttyd_options
212
251
  JSON.dump(
213
252
  fontSize: options.font_size,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DemoTape
4
- VERSION = "0.0.8"
4
+ VERSION = "0.0.9"
5
5
  end
data/lib/demo_tape.rb CHANGED
@@ -30,4 +30,5 @@ module DemoTape
30
30
  require_relative "demo_tape/formatter"
31
31
 
32
32
  ParseError = Class.new(StandardError)
33
+ TimeoutError = Class.new(StandardError)
33
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demotape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -279,7 +279,9 @@ files:
279
279
  - editors/vscode/demotape.tmLanguage.json
280
280
  - editors/vscode/icon.png
281
281
  - editors/vscode/language-configuration.json
282
+ - editors/vscode/package-lock.json
282
283
  - editors/vscode/package.json
284
+ - editors/vscode/snippets/demotape.json
283
285
  - editors/zed/extension.toml
284
286
  - editors/zed/grammars/demotape.wasm
285
287
  - editors/zed/languages/demotape/config.toml
@@ -691,10 +693,10 @@ metadata:
691
693
  rubygems_mfa_required: 'true'
692
694
  homepage_uri: https://github.com/fnando/demotape
693
695
  bug_tracker_uri: https://github.com/fnando/demotape/issues
694
- source_code_uri: https://github.com/fnando/demotape/tree/v0.0.8
695
- changelog_uri: https://github.com/fnando/demotape/tree/v0.0.8/CHANGELOG.md
696
- documentation_uri: https://github.com/fnando/demotape/tree/v0.0.8/README.md
697
- license_uri: https://github.com/fnando/demotape/tree/v0.0.8/LICENSE.md
696
+ source_code_uri: https://github.com/fnando/demotape/tree/v0.0.9
697
+ changelog_uri: https://github.com/fnando/demotape/tree/v0.0.9/CHANGELOG.md
698
+ documentation_uri: https://github.com/fnando/demotape/tree/v0.0.9/README.md
699
+ license_uri: https://github.com/fnando/demotape/tree/v0.0.9/LICENSE.md
698
700
  rdoc_options: []
699
701
  require_paths:
700
702
  - lib