3.0.0 • Published 5 years ago

simplywatch v3.0.0

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

SimplyWatch

Build Status Coverage Code Climate

A command line tool that monitors files under a given glob and individually executes commands (with optional dynamic placeholders) for the changed/added files.

What makes SimplyWatch different from the few similar packages available on NPM is:

  • It is intergrated with node-sass and simplyimport in which discovered files are scanned for import declarations and if SimplyWatch detects a change in any of the imported files, the provided command will be executed for the importing file. Example: 'FileA' and 'FileB' both import 'ChildFile' - when 'ChildFile' changes the command is executed for both 'FileA' and 'FileB'. Note that the imported file doesn't have to be in the provided glob, and will be watched for changes upon discovery.
  • It executes the commands concurrently. A scenario in which this is useful is when multiple files import the same child file and once the child file changes the command is executed for all importing files.
  • It provides debouncing: if a file is changed multiple times in a very short timeframe (i.e. under 2 seconds), the command will only be executed once in that time frame. Note: The default delay is 1500ms, and can be changed by specifying a different value to -d || -execDelay
  • It stacks execution tasks in order: If a file change triggers the command to be executed for it and then changes again (possibly multiple times) while the first command is still executing then the next commands will wait until the previous one finishes before being executed.
  • It can execute a final command after a given delay once SimplyWatch finishes processing a file change/addition batch. Example: once the compile command is executed for the source files, copy them to the dist/ folder and restart the server.
  • It can trim the messages outputted from the commands to a certain # of characters. This is useful for example when commands encounter an error they output the entire file's content in order to highlight a line that triggered the error, which can sometimes result in extremely large console outputs.

Installation:

npm install simplywatch

Usage:

Command Line Usage

simplywatch -g <glob> -x <command to execute> [options]

Options:

-g, --glob          glob/dir to watch. Multiple globs can be passed: -g "globA" "globB"
-i, --ignore        glob/dir to ignore. Multiple globs can be passed: -g "globA" "globB"
-x, --execute       Command to execute upon file addition/change
-f, --finally       Command to execute *once* after all changed files have been processed. Example: if a file change triggered a command to be executed for 10 files, this "finally" command will be executed after the time specified in --finallyDelay
-d, --delay         Execution delay, i.e. how long should simplywatch wait before re-executing the command. If the watched file changes rapidly, the command will execute only once every X ms
-D, --finallyDelay  The amount of milliseconds to wait before executing the "finally" command
-t, --trim          Trims the output of the command executions to only show the first X characters of the output
-s, --silent        Suppress any output from the executing command (including errors)
-b, --background    Run SimplyWatch as a background daemon
-l, --log           Path of the target log file when running in background mode
-h                  Show help
--version           Show version number                                  

Execution Command Placeholders

"path"  -  full path and filename
"root"  -  file root
"dir"   -  path without the filename
"reldir"-  directory name of file relative to the glob provided
"base"  -  file name and extension
"ext"   -  just file extension
"name"  -  just file name

Example:

simplywatch -g "assets/**" -x "node-sass #{path} -o dist/css/#{name}.css"
simplywatch -g "assets/*.coffee" -i "dontCompile/*" -x "cat {{path}} | coffee -s -c > dist/{{name}}.js"
3.0.0

5 years ago

3.0.0-l5

6 years ago

2.5.7

6 years ago

3.0.0-l4

6 years ago

3.0.0-l3

6 years ago

3.0.0-l2

7 years ago

3.0.0-l

7 years ago

3.0.0-k

7 years ago

2.5.5-republish

7 years ago

2.5.6

7 years ago

3.0.0-j

7 years ago

3.0.0-i

7 years ago

3.0.0-h

7 years ago

3.0.0-g

7 years ago

3.0.0-f

7 years ago

3.0.0-e

7 years ago

3.0.0-d

7 years ago

3.0.0-c

7 years ago

3.0.0-b

7 years ago

3.0.0-alpha

7 years ago

2.5.5

7 years ago

2.5.4

7 years ago

2.5.3

7 years ago

2.5.2

7 years ago

2.5.1

7 years ago

2.5.0

7 years ago

2.4.8

7 years ago

2.4.7

7 years ago

2.4.6

7 years ago

2.4.5

7 years ago

2.4.4

7 years ago

2.4.3

7 years ago

2.4.2

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago