node package manager


An watch-compile tool for nodejs.Useful for webdev real-time compilation such as less/coffee or what ever you want.



Only tested under linux.Nodejs's is used to watch file changes,but these API is not gareteed in all platform.The availability can be found at

An watch-compile tool for nodejs.Useful for webdev real-time compilation for less/coffee or what ever. # Install

sudo npm install -g watch-compile


watchcompile -f Watchfile -i 300 -s

-f is used to specify the Watchfile which contained watch rules. default is "./Watchfile" -i special the minimum recompile interval.Default is 500ms. -s compile all match rules at start

When change between minimum interval,the compile process will not be abort,and the latest change will not compiled.In order to prevent unwanted result the -i should be less than default settings.

When change happend after minimum compile interval,then an recompile will triggered,by your rules defined in Watchfile(latter example).But when the last change-compile is still running,That one will be aborted.


#create an default Watchfile at ./
watchcompile -c

A default Watchfile is like below

//{basename} /css/style.less => style.less 
//{fullpath} /css/style.less => /css/style.less (unchanged) 
//{filename} /css/style.less => style 
//{extname}  /css/style.less => .less 
//{directory} /css/style.less => /css/ 
exports.watchList = [
    [/^.*coffee$/,"coffee -c {fullpath}"]
    ,[/^.*less$/,"lessc {fullpath} > {directory}{basename}.css"]

Watchfile is considered as an standard node module and latter running by require("vm").runInContext. exports.watchList MUST be an Array of 2 dimension.Each of the elements contain [RegExp for matched file,cmdline for what to do when compile]

Consider the folder structure

/Watchfile  #this one is the example

When running watchcompile at /

/js/ is matched by [/^.*coffee$/,"coffee -c {fullpath}"]
/css/style.less is matched by [/^.*less$/,"lessc {fullpath} > {directory}{basename}.css"]

So when /js/ changed."coffee -c /js/" is excuted.

When /css/style.less changed."lessc /css/style.less > /css/style.css" is excuted.

Supported place holder are :

{basename} /css/style.less => style.less
{fullpath} /css/style.less => /css/style.less (unchanged)
{filename} /css/style.less => style
{extname}  /css/style.less => .less
{directory} /css/style.less => /css/


Since Watchfile is considered and excuted as node module.So you can do what ever you want in side to generate any exports.watchList you want in your own logic.