gulpfile.js
function reload(moduleName) {
    var id = require.resolve(moduleName);
    var mod = require.cache[id];
    if (mod) {
        var base = path.dirname(mod.filename);
        // expunge each module cache entry beneath this folder
        var stack = [mod];
        while (stack.length) {
            var mod = stack.pop();
            if (beneathBase(mod.filename)) {
                delete require.cache[mod.id];
            }
            stack.push.apply(stack, mod.children);
        }
    }

    // expunge each path cache entry beneath the folder
    for (var cacheKey in module.constructor._pathCache) {
        if (cacheKey.indexOf(moduleName) > 0 && beneathBase(cacheKey)) {
            delete module.constructor._pathCache[cacheKey];
        }
    }

    // re-require the module
    return require(moduleName);

    function beneathBase(file) {
        return base === undefined
            || (file.length > base.length
                && file.substr(0, base.length + 1) === base + path.sep);
    }
}
function reload(moduleName) {
    var id = require.resolve(moduleName);
    var mod = require.cache[id];
    if (mod) {
        var base = path.dirname(mod.filename);
        // expunge each module cache entry beneath this folder
        var stack = [mod];
        while (stack.length) {
            var mod = stack.pop();
            if (beneathBase(mod.filename)) {
                delete require.cache[mod.id];
            }
            stack.push.apply(stack, mod.children);
        }
    }

    // expunge each path cache entry beneath the folder
    for (var cacheKey in module.constructor._pathCache) {
        if (cacheKey.indexOf(moduleName) > 0 && beneathBase(cacheKey)) {
            delete module.constructor._pathCache[cacheKey];
        }
    }

    // re-require the module
    return require(moduleName);

    function beneathBase(file) {
        return base === undefined
            || (file.length > base.length
                && file.substr(0, base.length + 1) === base + path.sep);
    }
}
function reload ( moduleName ) { var id = require . resolve ( moduleName ) ; var mod = require . cache [ id ] ; if ( mod ) { var base = path . dirname ( mod . filename ) ; // expunge each module cache entry beneath this folder
 var stack = [ mod ] ; while ( stack . length ) { var mod = stack . pop ( ) ; if ( beneathBase ( mod . filename ) ) { delete require . cache [ mod . id ] ; } stack . push . apply ( stack , mod . children ) ; } } // expunge each path cache entry beneath the folder
 for ( var cacheKey in module . constructor . _pathCache ) { if ( cacheKey . indexOf ( moduleName ) > 0 && beneathBase ( cacheKey ) ) { delete module . constructor . _pathCache [ cacheKey ] ; } } // re-require the module
 return require ( moduleName ) ; function beneathBase ( file ) { return base === undefined || ( file . length > base . length && file . substr ( 0 , base . length + 1 ) === base + path . sep ) ; } }
reload a node module and any children beneath the same folder
reload a node module and any children beneath the same folder