mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
plugins: expose persistant data dir
Plugins need to be able to store persistant files, say settings or databases or similar things. Expose a standard location that gets created when the path is accessed.
This commit is contained in:
parent
bb4ab4f168
commit
02ccbc1f69
1 changed files with 7 additions and 0 deletions
|
@ -46,6 +46,7 @@ const packageApis = function (packageInfo) {
|
|||
},
|
||||
Config: {
|
||||
getConfig: () => Helper.config,
|
||||
getPersistentStorageDir: getPersistentStorageDir.bind(this, packageInfo.packageName),
|
||||
},
|
||||
Logger: {
|
||||
error: (...args) => log.error(...args),
|
||||
|
@ -87,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;
|
||||
|
|
Loading…
Reference in a new issue