code: function getFoldersRecursive (folder) {
      var fileContents = fs.readdirSync(folder),
          stats,
          folders = [];
  
      fileContents.forEach(function (fileName) {
          stats = fs.lstatSync(folder + '/' + fileName);
  
          if (stats.isDirectory()) {
            folders.push(folder + '/' + fileName);
            folders = folders.concat(getFoldersRecursive(folder + '/' + fileName));
          }
      });
  
      return folders;
  }
docs: Source: https://gist.github.com/ashblue/3916348