Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DoWatch

Actually listens to any change in the project folder and respawns the build process onchanges. To speed up things excludes from the build provess assets that do not need to be changed.

Hierarchy

  • DoWatch

Index

Constructors

constructor

Properties

Private config

config: YassbConfig

full YASSB configuration object.

Private firstRun

firstRun: boolean = true

Determines if it's the first time we are running the watcher.

Private isWatching

isWatching: boolean = true

Determines that we are in watch mode.

Methods

init

  • init(): Promise<void>
  • Inits do watch by first calling a full build process, and then initiating the watch function. We first do a non-watched build process to ensure everything is running smoothly. In a future update we could start directly with the watcher.

    Returns Promise<void>

Private sendReloadMessage

  • sendReloadMessage(): void
  • Sends a message to the browser via the WebSocket connection to reload the page at the end of the build process.

    Returns void

Private sendStartRebuildMessage

  • sendStartRebuildMessage(): void
  • Sends to the browser via the WebSocket connection the message the the rebuild process has started.

    Returns void

Private shouldDo

  • shouldDo(extension: ".ts" | ".js" | ".tsx" | ".jsx" | ".scss" | ".css", fileName: any): boolean
  • Determines if the changed file is of a given type to determine if we need to rebuild certain assets.

    Parameters

    • extension: ".ts" | ".js" | ".tsx" | ".jsx" | ".scss" | ".css"

      extension that we are looking for.

    • fileName: any

      the file that has changed.

    Returns boolean

    true if the file that has changed has the extension that we are looking for.

Private shouldRunScripts

  • shouldRunScripts(file: watcher.FileOrFiles): boolean
  • Determins if the file changes is a script and if scripts should run.

    Parameters

    • file: watcher.FileOrFiles

      the file that has changed.

    Returns boolean

    true if the file changed is a script.

Private shouldRunStyles

  • shouldRunStyles(file: watcher.FileOrFiles): boolean
  • Determins if the file changes is a stylesheet and if styles should run.

    Parameters

    • file: watcher.FileOrFiles

      the file that has changed.

    Returns boolean

    true if the file changed is a stylesheet.

Private shouldSkipTexts

  • shouldSkipTexts(runScripts: boolean, runStyles: boolean): boolean
  • Determines if it is unnecessary to rebuild text files

    Parameters

    • runScripts: boolean

      whether we need to run scripts.

    • runStyles: boolean

      whether we need to run styles.

    Returns boolean

    true if it's not the first run and we are rebuilding either scripts or styles.

Private watch

  • watch(): void
  • Watchs the src folder as defined in the config object and runs the builder on changes.

    Returns void