node-swatcher
TypeScript icon, indicating that this package has built-in type declarations

1.1.12 • Public • Published

My Package Icon

node-swatcher

node-swatcher is a lightweight file-watching tool, designed to automatically restart or reload file/script when the specified file changes. This tool is ideal if you want a simple file sandbox where you want to save time by not manually re-executing your file every time you make a change.

Features

  • Watches specified file for changes.
  • Automatically restarts the application on file update.
  • Has a cool json based config feature.

Installation

  • npm i node-swatcher or npm install node-swatcher
  • yarn add node-swatcher
  • Add required script to your package.json Alt Text

Usage

-Using Config File

  1. Create a swatcher.json file in the same directory as file to be run.
  2. Add the configurations as specified :
{
  "serverRestartMessage": "The Server has been restarted",
  "serverErrorMessage": "Try Fixing the error and then , retry",
  "fileChangeMessage": "File has been changed!",
  "filePath": "./demoFile.js",
  "command": "node"
}

Here command refers to the program to be used for running the file specified in the filePath.

  1. Run the command:
  • npm run swatch or yarn swatch

-Using CLI

  • First argument requied is the file path.

  • For running the node-swatcher using CLI we can pass the CLI equivalents of our json config as named args in the command.

For Example :

npm run swatch <filepath> --com=node
  • Remember --com is a required named argument.

Customizations

  • You can customize the restart,error and file change messages as required

Package Sidebar

Install

npm i node-swatcher

Weekly Downloads

8

Version

1.1.12

License

ISC

Unpacked Size

26.1 kB

Total Files

24

Last publish

Collaborators

  • swayam_1