Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more plugin functionality #4329

Merged
merged 3 commits into from Nov 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/plugins/packages/index.js
Expand Up @@ -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),
},
};
};
Expand Down Expand Up @@ -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;
Expand Down