jalapeno.js
function startWatching(watch_folder, dest_folder){

    var watch = require('watch');
    watch.watchTree(watch_folder, function (f, curr, prev) {
        if (typeof f == "object" && prev === null && curr === null) {

        // Finished walking the tree
        console.log('finished walking tree');
        
    } else if (prev === null) {

        // f is a new file
        console.log('new file: ' + f);
        var real_save_path = realDestinationPath(f, watch_folder, dest_folder);
        if (isDirectory(f, false)){
            //check if directory exists, if not create it
            isDirectory(real_save_path, true); 
        } else{
            //it's a file so let's copy it
            copyFileFrom(f, real_save_path);
        }

    } else if (curr.nlink === 0) {

        // f was removed
        console.log('removed file');
        if (isDirectory(f, false)){

        } else{
            removeFileAtPath(f, dest_folder);   
        }
    } else {

        // f was changed
        console.log('changed file f: ' + f);
        var real_save_path = realDestinationPath(f, watch_folder, dest_folder);
        
        if (isDirectory(f, false)){
            //check if directory exists, if not create it
            isDirectory(real_save_path, true); 
        } else{
            //it's a file so let's copy it
            copyFileFrom(f, real_save_path);
        }
    }
    });
}
function startWatching(watch_folder, dest_folder){

    var watch = require('watch');
    watch.watchTree(watch_folder, function (f, curr, prev) {
        if (typeof f == "object" && prev === null && curr === null) {

        // Finished walking the tree
        console.log('finished walking tree');
        
    } else if (prev === null) {

        // f is a new file
        console.log('new file: ' + f);
        var real_save_path = realDestinationPath(f, watch_folder, dest_folder);
        if (isDirectory(f, false)){
            //check if directory exists, if not create it
            isDirectory(real_save_path, true); 
        } else{
            //it's a file so let's copy it
            copyFileFrom(f, real_save_path);
        }

    } else if (curr.nlink === 0) {

        // f was removed
        console.log('removed file');
        if (isDirectory(f, false)){

        } else{
            removeFileAtPath(f, dest_folder);   
        }
    } else {

        // f was changed
        console.log('changed file f: ' + f);
        var real_save_path = realDestinationPath(f, watch_folder, dest_folder);
        
        if (isDirectory(f, false)){
            //check if directory exists, if not create it
            isDirectory(real_save_path, true); 
        } else{
            //it's a file so let's copy it
            copyFileFrom(f, real_save_path);
        }
    }
    });
}
functions