Merge pull request #4329 from brunnre8/plugins

Add more plugin functionality
This commit is contained in:
Max Leiter 2021-11-04 14:12:02 -07:00 committed by GitHub
commit 59280cfdfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,6 +46,13 @@ const packageApis = function (packageInfo) {
},
Config: {
getConfig: () => Helper.config,
getPersistentStorageDir: getPersistentStorageDir.bind(this, packageInfo.packageName),
},
Logger: {
error: (...args) => log.error(`[${packageInfo.packageName}]`, ...args),
warn: (...args) => log.warn(`[${packageInfo.packageName}]`, ...args),
info: (...args) => log.info(`[${packageInfo.packageName}]`, ...args),
debug: (...args) => log.debug(`[${packageInfo.packageName}]`, ...args),
},
};
};
@ -81,6 +88,12 @@ function getEnabledPackages(packageJson) {
return [];
}
function getPersistentStorageDir(packageName) {
const dir = path.join(Helper.getPackagesPath(), packageName);
fs.mkdirSync(dir, {recursive: true}); // we don't care if it already exists or not
return dir;
}
function loadPackage(packageName) {
let packageInfo;
let packageFile;