From 6108064ea8e9e6a9bb0a5bff7da1d36bb08363e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 20 May 2020 12:43:20 -0400 Subject: [PATCH] feat: change to contains to match scoped modules replace recursive function with loop --- Gruntfile.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index b0a6abd548..5beb0895f2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -179,23 +179,22 @@ module.exports = function (grunt) { }; function addBaseThemes(plugins) { - const themeId = plugins.find(p => p.startsWith('nodebb-theme-')); + let themeId = plugins.find(p => p.contains('nodebb-theme-')); if (!themeId) { return plugins; } - function getBaseRecursive(themeId) { + let baseTheme; + do { try { - const baseTheme = require(themeId + '/theme').baseTheme; - - if (baseTheme) { - plugins.push(baseTheme); - getBaseRecursive(baseTheme); - } + baseTheme = require(themeId + '/theme').baseTheme; } catch (err) { console.log(err); } - } - getBaseRecursive(themeId); + if (baseTheme) { + plugins.push(baseTheme); + themeId = baseTheme; + } + } while (baseTheme); return plugins; }