class Guard::TypeScript

The TypeScript guard that gets notifications about the following Guard events: ‘start`, `stop`, `reload`, `run_all` and `run_on_change`.

Constants

DEFAULT_OPTIONS

Public Class Methods

new(watchers = [], options = {}) click to toggle source

Initialize Guard::TypeScript.

@param [Array<Guard::Watcher>] watchers the watchers in the Guard block @param [Hash] options the options for the Guard @option options [String] :input the input directory @option options [String] :output the output directory @option options [Boolean] :concatenate combine dependencies into files @option options [Boolean] :shallow do not create nested directories @option options [Boolean] :hide_success hide success message notification @option options [Boolean] :all_on_start generate all JavaScripts files on start @option options [Boolean] :source_map generate the source map files

Calls superclass method
# File lib/guard/typescript.rb, line 34
def initialize(watchers = [], options = {})
  watchers = [] if !watchers
  defaults = DEFAULT_OPTIONS.clone

  if options[:input]
    defaults.merge!({ :output => options[:input] })
    watchers << ::Guard::Watcher.new(%r{^#{ options[:input] }/(.+\.(?:ts))$})
  end

  super(watchers, defaults.merge(options))
end

Public Instance Methods

run_all() click to toggle source

Gets called when all files should be regenerated.

@raise [:task_has_failed] when stop has failed

# 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) click to toggle source

Gets called when watched paths and files have changes.

@param [Array<String>] paths the changed paths and files @raise [:task_has_failed] when stop has failed

# File lib/guard/typescript.rb, line 67
def run_on_modifications(paths)
  changed_files, success = Runner.run(Inspector.clean(paths), watchers, options)

  throw :task_has_failed unless success
end
run_on_removals(paths) click to toggle source

Called on file(s) deletions that the Guard watches.

@param [Array<String>] paths the deleted files or paths @raise [:task_has_failed] when run_on_change has failed

# File lib/guard/typescript.rb, line 78
def run_on_removals(paths)
  Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, options)
end
start() click to toggle source

Gets called once when Guard starts.

@raise [:task_has_failed] when stop has failed

# File lib/guard/typescript.rb, line 50
def start
  run_all if options[:all_on_start]
end