Home Manual Reference Source
import {BuildNodeRunnerProcess} from 'projext/src/services/building/buildNodeRunnerProcess.js'
public class | source

BuildNodeRunnerProcess

Extends:

NodeWatcher → BuildNodeRunnerProcess

This service implements nodemon and NodeWatcher in order to run Node apps while watching, transpiling and copying files.

Constructor Summary

Public Constructor
public

constructor(appLogger: Logger, buildTranspiler: BuildTranspiler, projectConfiguration: ProjectConfigurationSettings)

Member Summary

Public Members
public

A local reference for the appLogger service.

public

A local reference for the buildTranspiler service.

public

defaultOptions: {"executable": *, "inspectOptions": *, "watch": *, "ignore": *, "envVars": *, "legacyWatch": *}

The default values for the options that can be customized when calling run.

public

This dictionary is where the parameters sent to the run method and the defaultOptions will be merged.

public

A simple flag to check whether the process is running or not.

Method Summary

Public Methods
public

Enables nodemon legacy watch mode.

public

run(executable: string, watch: Array, inspectOptions: NodeInspectorSettings, transpilationPaths: Array, copyPaths: Array, envVars: Object, ignore: Array, setupFn: Function(instance:BuildNodeRunnerProcess)): Nodemon

Run a Node application.

Inherited Summary

From class NodeWatcher
public

Whether or not the service is watching.

private

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

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(appLogger: Logger, buildTranspiler: BuildTranspiler, projectConfiguration: ProjectConfigurationSettings) source

Override:

NodeWatcher#constructor

Params:

NameTypeAttributeDescription
appLogger Logger

The inform on the CLI of the events of the runner.

buildTranspiler BuildTranspiler

To transpile files if needed.

projectConfiguration ProjectConfigurationSettings

To read the watch settings.

Public Members

public appLogger: Logger source

A local reference for the appLogger service.

public buildTranspiler: BuildTranspiler source

A local reference for the buildTranspiler service.

public defaultOptions: {"executable": *, "inspectOptions": *, "watch": *, "ignore": *, "envVars": *, "legacyWatch": *} source

The default values for the options that can be customized when calling run.

Properties:

NameTypeAttributeDescription
executable string

The path to the file nodemon will execute.

inspectOptions NodeInspectorSettings

The settings for the Node inspector.

watch Array

The list of directories nodemon will watch in orderto reset the execution.

ignore Array

A list of patterns nodemon will ignore while watching directories.

envVars Object

A dictionary of environment variables to send to the execution process.

legacyWatch boolean

Whether or not to enable nodemon legacy watch mode.

public options: Object source

This dictionary is where the parameters sent to the run method and the defaultOptions will be merged.

public running: boolean source

A simple flag to check whether the process is running or not.

Public Methods

public enableLegacyWatch() source

Enables nodemon legacy watch mode.

See:

public run(executable: string, watch: Array, inspectOptions: NodeInspectorSettings, transpilationPaths: Array, copyPaths: Array, envVars: Object, ignore: Array, setupFn: Function(instance:BuildNodeRunnerProcess)): Nodemon source

Run a Node application.

Params:

NameTypeAttributeDescription
executable string

The path to the file to execute.

watch Array

The list of directories to watch in order to restart the application.

inspectOptions NodeInspectorSettings

The settings for the Node inspector.

transpilationPaths Array
  • optional
  • default: []

A list of dictionaries with from and to paths the service will use for transpilation when files change during the execution, in order to restart the application.

copyPaths Array
  • optional
  • default: []

A list of dictionaries with from and to paths the service will use for copying files when they change during the execution, in order to restart the application.

envVars Object
  • optional
  • default: {}

A dictionary with extra environment variables to send to the execution process.

ignore Array
  • optional
  • default: ['.test.js']

A list of file name patterns the service that will be ignored by the nodemon watcher.

setupFn Function(instance:BuildNodeRunnerProcess)
  • optional

A custom callback that will be executed before starting (and restaring) a Node application. It can be used to "modify the environment" before the application runs.

Return:

Nodemon

Throw:

Error

if the process is already running.

Error

if the executable doesn't exist.

TODO:

  • refactor the parameters into a single "options object".
  • watch the .env files.