diff --git a/src/plugins/packages/index.js b/src/plugins/packages/index.js index 53b16cd0..f6d5ed6e 100644 --- a/src/plugins/packages/index.js +++ b/src/plugins/packages/index.js @@ -11,6 +11,7 @@ const fs = require("fs"); const Utils = require("../../command-line/utils"); const stylesheets = []; +const files = []; const TIME_TO_LIVE = 15 * 60 * 1000; // 15 minutes, in milliseconds @@ -19,6 +20,7 @@ const cache = { }; module.exports = { + getFiles, getStylesheets, getPackage, loadPackages, @@ -30,6 +32,9 @@ const packageApis = function(packageName) { Stylesheets: { addFile: addStylesheet.bind(this, packageName), }, + PublicFiles: { + add: addFile.bind(this, packageName), + }, Commands: { add: inputs.addPluginCommand, runAsUser: (command, targetId, client) => @@ -49,6 +54,14 @@ function getStylesheets() { return stylesheets; } +function addFile(packageName, filename) { + files.push(packageName + "/" + filename); +} + +function getFiles() { + return files.concat(stylesheets); +} + function getPackage(name) { return packageMap.get(name); } @@ -90,6 +103,10 @@ function loadPackages() { if (packageInfo.type === "theme") { themes.addTheme(packageName, packageInfo); + + if (packageInfo.files) { + packageInfo.files.forEach((file) => addFile(packageName, file)); + } } else { anyPlugins = true; } diff --git a/src/server.js b/src/server.js index ffd7bf47..38f2e05b 100644 --- a/src/server.js +++ b/src/server.js @@ -79,7 +79,7 @@ module.exports = function() { const fileName = req.params.filename; const packageFile = packages.getPackage(packageName); - if (!packageFile || !packages.getStylesheets().includes(`${packageName}/${fileName}`)) { + if (!packageFile || !packages.getFiles().includes(`${packageName}/${fileName}`)) { return res.status(404).send("Not found"); }