Home Manual Reference Source
import NodeWatcher from 'projext/src/abstracts/nodeWatcher.js'
public class | version 1.0 | source

NodeWatcher

A helper class for creating services that rely on watching directories and copying and/or transpiling files.

Constructor Summary

Public Constructor
public

constructor(watchpackOptions: WatchpackOptions)

Member Summary

Public Members
public

Whether or not the service is watching.

Private Members
private

This will be the instance of watchpack when the service starts watching the files.

Method Summary

Public Methods
public

Gets the list of paths the service is watching.

public

stop()

Stops watching the directories.

public

watch(paths: Array, transpilationPaths: Array, copyPaths: Array): Watchpack

Starts watching the directories.

Public Constructors

public constructor(watchpackOptions: WatchpackOptions) source

Params:

NameTypeAttributeDescription
watchpackOptions WatchpackOptions
  • optional
  • default: {}

Custom options for watchpack, the library being used to watch directories.

Public Members

public watching: boolean source

Whether or not the service is watching.

Private Members

private _watcher: Watchpack source

This will be the instance of watchpack when the service starts watching the files.

Public Methods

public getPaths(): Array source

Gets the list of paths the service is watching.

Return:

Array

public stop() source

Stops watching the directories.

public watch(paths: Array, transpilationPaths: Array, copyPaths: Array): Watchpack source

Starts watching the directories.

Params:

NameTypeAttributeDescription
paths Array

The list of directories the service will watch.

transpilationPaths Array
  • optional
  • default: []

A list of dictionaries with from and to paths for transpilation. When a file change is detected by the service, it will try to match the file path with the from property of one of the items, and if one is found, it will call the method to transpile that file using item's paths.

copyPaths Array
  • optional
  • default: []

A list of dictionaries with from and to paths for copying files. When a file change is detected by the service, and if the file path doesn't match any of the transpilation paths, it will try to match the from of an item from this list. If one is found, it will then call the method to copy that file using item's paths.

Return:

Watchpack