diff --git a/lib/mods.js b/lib/mods.js index 1b6d6eb..190670c 100644 --- a/lib/mods.js +++ b/lib/mods.js @@ -6,8 +6,6 @@ var _ = require('lodash'); var path = require('path'); var playwithsix = require('playwithsix'); -var traverse = require('./mods/traverse'); - var Mods = function (config) { this.config = config; this.liteMods = true; @@ -148,8 +146,4 @@ Mods.prototype.search = function (query, cb) { }); }; -Mods.prototype.traverse = function (mod, cb) { - traverse(path.join(this.config.path, mod), cb); -}; - module.exports = Mods; diff --git a/lib/mods/traverse.js b/lib/mods/traverse.js deleted file mode 100644 index d4fa727..0000000 --- a/lib/mods/traverse.js +++ /dev/null @@ -1,49 +0,0 @@ -var nodefn = require('when/node/function'); -var fs = require('fs'); -var path = require('path'); -var when = require('when'); - -function walk (directory) { - createFile = function (file, stat) { - return { - type: "file", - name: file, - size: stat.size - }; - }; - - createFolder = function (folder) { - return { - type: "folder", - name: folder, - files: [] - }; - }; - - var results = []; - - return when.map(nodefn.call(fs.readdir, directory), function(file) { - var absolutePath = path.join(directory, file); - return nodefn.call(fs.stat, absolutePath).then(function(stat) { - if (stat.isFile()) { - return results.push(createFile(file, stat)); - } - - folder = createFolder(file); - return walk(absolutePath).then(function(filesInDir) { - folder.files = filesInDir; - results.push(folder); - }); - }); - }).then(function() { - return results; - }); -} - -module.exports = function (path, cb) { - walk(path).then(function(files) { - cb(null, files); - }).otherwise(function(error) { - cb(error); - }); -}; diff --git a/package.json b/package.json index 5823bef..c231aa0 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "socket.io": "^1.0.4", "steam-workshop": "0.0.1", "userhome": "^1.0.0", - "when": "~3.1.0", "winser": "^1.0.2" }, "devDependencies": { diff --git a/routes/mods.js b/routes/mods.js index ec639ce..95fe700 100644 --- a/routes/mods.js +++ b/routes/mods.js @@ -9,17 +9,6 @@ module.exports = function (modsManager) { res.send(204, {}); }, - show: function(req, res){ - modsManager.traverse(req.params.mod, function (err, files) { - if (err || !files) { - console.error(err.stack || err); - res.send(500, err); - } else { - res.json(files); - } - }); - }, - update: function(req, res){ modsManager.download(req.params.mod); res.send(204, {});