common/fs/deep-watch.js
function watch (dir) {
  if (!ignoreDir.test(dir) && !map[dir]) {
    fs.lstat(dir, function (e, stat) {
      if (!e) {
        if (stat.isSymbolicLink()) {
          var source = dir
          fs.readlink(source, function (e, link) {
            if (!e) {
              var dest = link
              if (dest[0] !== '/') {
                while (dest.substr(0, 3) === '../') {
                  dest = dest.substr(3)
                  source = source.replace(/\/[^\/]+$/, '')
                }
                if (dest.substr(0, 2) === './') {
                  dest = dest.substr(2)
                }
                dest = source + '/' + dest
              }
              watch(dest)
            }
          })
        } else if (stat.isDirectory()) {
          addDir(dir, stat)
        } else {
          dir = dirname(dir)
          map[dir] = Math.max(map[dir], stat.mtime.getTime())
        }
      }
    })
  }
}
function watch (dir) {
  if (!ignoreDir.test(dir) && !map[dir]) {
    fs.lstat(dir, function (e, stat) {
      if (!e) {
        if (stat.isSymbolicLink()) {
          var source = dir
          fs.readlink(source, function (e, link) {
            if (!e) {
              var dest = link
              if (dest[0] !== '/') {
                while (dest.substr(0, 3) === '../') {
                  dest = dest.substr(3)
                  source = source.replace(/\/[^\/]+$/, '')
                }
                if (dest.substr(0, 2) === './') {
                  dest = dest.substr(2)
                }
                dest = source + '/' + dest
              }
              watch(dest)
            }
          })
        } else if (stat.isDirectory()) {
          addDir(dir, stat)
        } else {
          dir = dirname(dir)
          map[dir] = Math.max(map[dir], stat.mtime.getTime())
        }
      }
    })
  }
}
function watch ( dir ) { if ( ! ignoreDir . test ( dir ) && ! map [ dir ] ) { fs . lstat ( dir , function ( e , stat ) { if ( ! e ) { if ( stat . isSymbolicLink ( ) ) { var source = dir fs . readlink ( source , function ( e , link ) { if ( ! e ) { var dest = link if ( dest [ 0 ] !== '/' ) { while ( dest . substr ( 0 , 3 ) === '../' ) { dest = dest . substr ( 3 ) source = source . replace ( / \/[^\/]+$ / , '' ) } if ( dest . substr ( 0 , 2 ) === './' ) { dest = dest . substr ( 2 ) } dest = source + '/' + dest } watch ( dest ) } } ) } else if ( stat . isDirectory ( ) ) { addDir ( dir , stat ) } else { dir = dirname ( dir ) map [ dir ] = Math . max ( map [ dir ] , stat . mtime . getTime ( ) ) } } } ) } }
Recurse to find directories we can watch.
Recurse to find directories we can watch .