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

npm install watch-compile
2 downloads in the last day
7 downloads in the last week
55 downloads in the last month



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.


sudo npm install -g watch-compile


watchcompile -f Watchfile -i 300

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

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.

npm loves you