From 5d6522d52077e67dc7c81a080f91e28542dd008d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Dahlgren?= Date: Sat, 26 Dec 2020 13:56:59 +0100 Subject: [PATCH] Find mod folders recursively --- lib/mods.js | 10 +++++----- package.json | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mods.js b/lib/mods.js index 466c194..a8ad0ae 100644 --- a/lib/mods.js +++ b/lib/mods.js @@ -1,5 +1,6 @@ var events = require('events') var fs = require('fs.extra') +var glob = require('glob') var path = require('path') var Mods = function (config) { @@ -22,15 +23,14 @@ Mods.prototype.delete = function (mod, cb) { Mods.prototype.updateMods = function () { var self = this - fs.readdir(self.config.path, function (err, files) { + glob('**/@*/addons', { cwd: self.config.path }, function (err, files) { if (err) { console.log(err) } else { - var mods = files.filter(function (file) { - return file.charAt(0) === '@' - }).map(function (name) { + var mods = files.map(function (file) { return { - name: name + // Find actual parent mod folder from addons folder + name: path.join(file, '..') } }) diff --git a/package.json b/package.json index b2f6af2..f4f294b 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "filesize": "^3.1.0", "fs.extra": "~1.3.2", "gamedig": "^0.2.30", + "glob": "^7.1.6", "jquery": "^3.5.0", "jquery.iframe-transport": "^1.0.0", "ladda": "1.0.5",