diff options
author | 0neGal <mail@0negal.com> | 2023-07-21 23:35:34 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-07-21 23:35:34 +0200 |
commit | a8174ea74b81db2ada3d0a519cd58de4939a67a8 (patch) | |
tree | 4f7ec7c091d8ad642e93fd0518d3313a6388fa62 /src/modules/packages.js | |
parent | b08e4d193a2c6dea82a6f00432203cfad097e708 (diff) | |
download | Viper-a8174ea74b81db2ada3d0a519cd58de4939a67a8.tar.gz Viper-a8174ea74b81db2ada3d0a519cd58de4939a67a8.zip |
mods from packages can be removed in the frontend
I also love how I spent a very long time trying to figure out why
Electron's serializer was failing, turns out, it just throws errors when
it encounters functions, instead of stripping them out, like
`JSON.stringify()` does
Oh well...
Diffstat (limited to 'src/modules/packages.js')
-rw-r--r-- | src/modules/packages.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/modules/packages.js b/src/modules/packages.js index 25416c4..12659fe 100644 --- a/src/modules/packages.js +++ b/src/modules/packages.js @@ -46,7 +46,7 @@ packages.split_name = (name) => { } } -packages.list = (dir = packages.path) => { +packages.list = (dir = packages.path, no_functions) => { let files = fs.readdirSync(dir); let package_list = {}; @@ -93,13 +93,16 @@ packages.list = (dir = packages.path) => { package_list[files[i]].has_mods = true; } - // add `.remove()` function, mostly just a shorthand - package_list[files[i]].remove = () => { - return packages.remove( - split_name.author, - split_name.package_name, - split_name.version, - ) + // add `.remove()` function, mostly just a shorthand, + // unless `no_functions` is `true` + if (! no_functions) { + package_list[files[i]].remove = () => { + return packages.remove( + split_name.author, + split_name.package_name, + split_name.version, + ) + } } // set the `.icon` property |