Support scoped theme packages

This commit is contained in:
Peter Jaszkowiak
2018-06-09 16:26:28 -06:00
committed by Julian Lam
parent d656c65c9a
commit 70ff2d9b88
10 changed files with 98 additions and 29 deletions

View File

@@ -34,8 +34,11 @@ function buildTargets() {
);
}
var themeNamePattern = /^(@.*?\/)?nodebb-theme-.*$/;
var pluginNamePattern = /^(@.*?\/)?nodebb-(theme|plugin|widget|rewards)-.*$/;
function activate(plugin) {
if (plugin.startsWith('nodebb-theme-')) {
if (themeNamePattern.test(plugin)) {
reset.reset({
theme: plugin,
}, function (err) {
@@ -50,7 +53,7 @@ function activate(plugin) {
db.init(next);
},
function (next) {
if (!plugin.startsWith('nodebb-')) {
if (!pluginNamePattern.test(plugin)) {
// Allow omission of `nodebb-plugin-`
plugin = 'nodebb-plugin-' + plugin;
}

View File

@@ -14,6 +14,9 @@ var widgets = require('../widgets');
var dirname = require('./paths').baseDir;
var themeNamePattern = /^(@.*?\/)?nodebb-theme-.*$/;
var pluginNamePattern = /^(@.*?\/)?nodebb-(theme|plugin|widget|rewards)-.*$/;
exports.reset = function (options, callback) {
var map = {
theme: function (next) {
@@ -21,7 +24,7 @@ exports.reset = function (options, callback) {
if (themeId === true) {
resetThemes(next);
} else {
if (!themeId.startsWith('nodebb-theme-')) {
if (!themeNamePattern.test(themeId)) {
// Allow omission of `nodebb-theme-`
themeId = 'nodebb-theme-' + themeId;
}
@@ -34,7 +37,7 @@ exports.reset = function (options, callback) {
if (pluginId === true) {
resetPlugins(next);
} else {
if (!pluginId.startsWith('nodebb-plugin-')) {
if (!pluginNamePattern.test(pluginId)) {
// Allow omission of `nodebb-plugin-`
pluginId = 'nodebb-plugin-' + pluginId;
}