Method: ReactNativeUtil::Util#run_command_with_spinner!
- Defined in:
- lib/react_native_util/util.rb
#run_command_with_spinner!(*command, log: nil, chdir: nil) ⇒ Object
Executes a command with no output to the terminal. A spinner is displayed instead. Output may be directed to a file.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/react_native_util/util.rb', line 17 def run_command_with_spinner!(*command, log: nil, chdir: nil) STDOUT.flush STDERR.flush spinner = TTY::Spinner.new "[:spinner] #{command.shelljoin}", format: :flip spinner.auto_spin start_time = Time.now execute(*command, log: nil, output: log, chdir: chdir) spinner.success "success in #{elapsed_from start_time} s" rescue ExecutionError spinner.error "failure in #{elapsed_from start_time} s" STDOUT.log "See #{log} for details." if log && log.kind_of?(String) raise end |