Class: Guard::TypeScript
- Defined in:
- lib/guard/typescript.rb,
lib/guard/typescript/runner.rb,
lib/guard/typescript/formatter.rb,
lib/guard/typescript/inspector.rb
Overview
The TypeScript guard that gets notifications about the following Guard events: ‘start`, `stop`, `reload`, `run_all` and `run_on_change`.
Defined Under Namespace
Modules: Formatter, Inspector, Runner
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :shallow => false, :hide_success => false, :error_to_js => false, :all_on_start => false, :source_map => false }
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ TypeScript
constructor
Initialize Guard::TypeScript.
-
#run_all ⇒ Object
Gets called when all files should be regenerated.
-
#run_on_modifications(paths) ⇒ Object
Gets called when watched paths and files have changes.
-
#run_on_removals(paths) ⇒ Object
Called on file(s) deletions that the Guard watches.
-
#start ⇒ Object
Gets called once when Guard starts.
Constructor Details
#initialize(watchers = [], options = {}) ⇒ TypeScript
Initialize Guard::TypeScript.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/guard/typescript.rb', line 34 def initialize(watchers = [], = {}) watchers = [] if !watchers defaults = DEFAULT_OPTIONS.clone if [:input] defaults.merge!({ :output => [:input] }) watchers << ::Guard::Watcher.new(%r{^#{ [:input] }/(.+\.(?:ts))$}) end super(watchers, defaults.merge()) end |
Instance Method Details
#run_all ⇒ Object
Gets called when all files should be regenerated.
58 59 60 |
# File 'lib/guard/typescript.rb', line 58 def run_all run_on_modifications(Watcher.match_files(self, Dir.glob('**{,/*/**}/*.ts'))) end |
#run_on_modifications(paths) ⇒ Object
Gets called when watched paths and files have changes.
67 68 69 70 71 |
# File 'lib/guard/typescript.rb', line 67 def run_on_modifications(paths) changed_files, success = Runner.run(Inspector.clean(paths), watchers, ) throw :task_has_failed unless success end |
#run_on_removals(paths) ⇒ Object
Called on file(s) deletions that the Guard watches.
78 79 80 |
# File 'lib/guard/typescript.rb', line 78 def run_on_removals(paths) Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, ) end |
#start ⇒ Object
Gets called once when Guard starts.
50 51 52 |
# File 'lib/guard/typescript.rb', line 50 def start run_all if [:all_on_start] end |